From dca2d2693a90c4376eb8faf3e7e339cebfd6842e Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Wed, 24 Apr 2024 14:54:44 -0700 Subject: [PATCH 1/3] gha: bump action version. --- .github/workflows/tag-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 48212ab..25f53f2 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -35,7 +35,7 @@ jobs: echo "::notice::Version STR=${VERSION_STR}${ALT_TAGS}" - name: "Create Release" - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From 50122fa2693b43f22697bdd8e789066b65a504d7 Mon Sep 17 00:00:00 2001 From: Jeremy Steele Date: Mon, 24 Jun 2024 09:57:14 -0400 Subject: [PATCH 2/3] Use scheme for processing --- handlers/postmaster/postmaster.go | 62 ++++++++++++------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/handlers/postmaster/postmaster.go b/handlers/postmaster/postmaster.go index 4081d43..009fc04 100644 --- a/handlers/postmaster/postmaster.go +++ b/handlers/postmaster/postmaster.go @@ -116,7 +116,6 @@ func (h *handler) receiveMessage(ctx context.Context, channel courier.Channel, w } var urn urns.URN - mode := strings.ToUpper(payload.Mode) if len(channel.Schemes()) < 1 { return nil, fmt.Errorf("no scheme set for channel %s", channel.UUID()) @@ -128,7 +127,7 @@ func (h *handler) receiveMessage(ctx context.Context, channel courier.Channel, w urns.ValidSchemes[scheme] = true //Handle SMS (tel) specially, everything else is a straight string passthrough - if mode == "SMS" { + if scheme == "tel" { // Remove out + and - just in case value := payload.Contact.Value value = strings.Replace(value, " ", "", -1) @@ -200,11 +199,6 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat return nil, err } - chatMode := msg.Channel().ConfigForKey("chat_mode", "").(string) - if chatMode == "" { - return nil, fmt.Errorf("invalid chat mode") - } - deviceId := msg.Channel().Address() status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) @@ -227,9 +221,9 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat payload.Contact.Name = string(dbContact.Name_) payload.Contact.Value = msg.URN().Path() payload.Text = part - payload.Mode = strings.ToUpper(chatMode) payload.ChannelID = msg.Channel().UUID().String() payload.DeviceID = deviceId + payload.Scheme = msg.Channel().Schemes()[0] payload.ID = fmt.Sprintf("%d", msg.ID()) for _, attachment := range msg.Attachments() { @@ -274,16 +268,11 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat } func (h *handler) PurgeOutgoing(ctx context.Context, channel courier.Channel) error { - chatMode := channel.ConfigForKey("chat_mode", "").(string) - if chatMode == "" { - return fmt.Errorf("invalid chat mode") - } - deviceID := channel.Address() pr := purgeRequest{ DeviceID: deviceID, - Mode: chatMode, + Scheme: channel.Schemes()[0], } apiUrl, err := getPostofficeEndpoint() @@ -356,7 +345,6 @@ Content-Type: application/json; charset=utf-8 "name": "Bob", "value": "tel:+11234567890" }, - "mode": "sms", "channel_id": "7cc23772-e933-47b4-b025-19cbaec01edf", "media": ["http://example.com/example.jpg"] } @@ -369,25 +357,23 @@ type incomingMessage struct { Name string `json:"name"` Value string `json:"value" validate:"required"` } `json:"contact" validate:"required"` - Mode string `json:"mode" validate:"required"` ChannelID string `json:"channel_id" validate:"required"` Media []string ` json:"media"` } /* -{ - "text": "bla", - "contact": { - "name": "Bob", - "value": "tel:+11234567890" - }, - "mode": "sms", - "channel_id": "7cc23772-e933-47b4-b025-19cbaec01edf", - "device_id": "7cc23773-e933-47b4-b025-19cbaec01edf", - "id": "32423432432", - "media": ["http://example.com/example.jpg"] -} + { + "text": "bla", + "contact": { + "name": "Bob", + "value": "tel:+11234567890" + }, + "channel_id": "7cc23772-e933-47b4-b025-19cbaec01edf", + "device_id": "7cc23773-e933-47b4-b025-19cbaec01edf", + "id": "32423432432", + "media": ["http://example.com/example.jpg"] + } */ type outgoingMessage struct { Text string `json:"text" validate:"required"` @@ -395,9 +381,9 @@ type outgoingMessage struct { Name string `json:"name"` Value string `json:"value" validate:"required"` } `json:"contact" validate:"required"` - Mode string `json:"mode" validate:"required"` DeviceID string `json:"device_id" validate:"required"` ChannelID string `json:"channel_id" validate:"required"` + Scheme string `json:"scheme" validate:"required"` ID string `json:"id" validate:"required"` @@ -405,10 +391,10 @@ type outgoingMessage struct { } /* -{ - "message_id": "1234", - "status": "S" -} + { + "message_id": "1234", + "status": "S" + } */ type messageStatus struct { MessageID string `json:"message_id" validate:"required"` @@ -416,12 +402,12 @@ type messageStatus struct { } /* -{ - "device_id": "123", - "mode": "SMS" -} + { + "device_id": "123", + "channel_id": "12121-dsfsdf-3243-dsfsdf-2323" + } */ type purgeRequest struct { DeviceID string `json:"device_id" validate:"required"` - Mode string `json:"mode" validate:"required"` + Scheme string `json:"scheme" validate:"required"` } From 61f88c3f16123be24fc2dbf62a5d3b8cca03b809 Mon Sep 17 00:00:00 2001 From: Jeremy Steele Date: Mon, 24 Jun 2024 16:39:05 -0400 Subject: [PATCH 3/3] Fix purge --- handlers/postmaster/postmaster.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/handlers/postmaster/postmaster.go b/handlers/postmaster/postmaster.go index 009fc04..1ba9e35 100644 --- a/handlers/postmaster/postmaster.go +++ b/handlers/postmaster/postmaster.go @@ -268,11 +268,8 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat } func (h *handler) PurgeOutgoing(ctx context.Context, channel courier.Channel) error { - deviceID := channel.Address() - pr := purgeRequest{ - DeviceID: deviceID, - Scheme: channel.Schemes()[0], + ChannelId: channel.UUID().String(), } apiUrl, err := getPostofficeEndpoint() @@ -408,6 +405,5 @@ type messageStatus struct { } */ type purgeRequest struct { - DeviceID string `json:"device_id" validate:"required"` - Scheme string `json:"scheme" validate:"required"` + ChannelId string `json:"channel_id"` }