diff --git a/connectors/semaphore/semaphore.go b/connectors/semaphore/semaphore.go index abfe240..7949132 100644 --- a/connectors/semaphore/semaphore.go +++ b/connectors/semaphore/semaphore.go @@ -216,12 +216,24 @@ func (s *semaphore) Resolve(_ context.Context, action string, raw jsontext.Value if err != nil { return nil, err } + effect := s.effect(t) + effect.Summary = fill(effect.Summary, in) return &connectorv1.ResolveResponse{ Target: &connectorv1.Target{Kind: t.Target.Kind, Id: in.Host, Environment: t.Target.Environment, Disposable: t.Target.Disposable}, - Effect: s.effect(t), + Effect: effect, }, nil } +// fill puts this action's values into a declared summary's {host} and {var} +// placeholders, so the person approving it reads what this one does. +func fill(summary string, in actionInput) string { + pairs := []string{"{host}", in.Host} + for name, v := range in.Vars { + pairs = append(pairs, "{"+name+"}", v) + } + return strings.NewReplacer(pairs...).Replace(summary) +} + type task struct { ID int `json:"id"` TemplateID int `json:"template_id"` diff --git a/connectors/telegram/telegram.go b/connectors/telegram/telegram.go index 0dd77bc..d3f6567 100644 --- a/connectors/telegram/telegram.go +++ b/connectors/telegram/telegram.go @@ -127,8 +127,14 @@ func (t *telegram) Deliver(ctx context.Context, delivery string, input jsontext. type update struct { UpdateID int64 `json:"update_id"` Callback *struct { - ID string `json:"id"` - Data string `json:"data"` + ID string `json:"id"` + Data string `json:"data"` + Message *struct { + MessageID int64 `json:"message_id"` + Chat struct { + ID int64 `json:"id"` + } `json:"chat"` + } `json:"message"` From struct { ID int64 `json:"id"` FirstName string `json:"first_name"` @@ -205,9 +211,20 @@ func (t *telegram) answer(ctx context.Context, u update) (*connector.Event, func if err != nil { return nil, tell("That answer couldn't be read.") } + received := tell("Answer received.") return &connector.Event{ Type: answerType, SourceEventID: "update:" + strconv.FormatInt(u.UpdateID, 10), Fields: fields, OccurredAt: time.Now().UTC(), - }, tell("Answer received.") + }, func() { + received() + // The buttons go once the answer is stored, so nobody taps a settled + // request again. + if q.Message != nil { + _ = t.call(ctx, "editMessageReplyMarkup", map[string]any{ + "chat_id": q.Message.Chat.ID, "message_id": q.Message.MessageID, + "reply_markup": map[string]any{"inline_keyboard": [][]any{}}, + }, nil) + } + } } // parseAnswer reads a button's data: "answer::".