Skip to content

Commit

Permalink
Merge pull request #687 from nyaruka/unavailable_attachments
Browse files Browse the repository at this point in the history
Save un-fetchable attachments instead of erroring
  • Loading branch information
rowanseymour authored Nov 11, 2022
2 parents 7afc8ed + cc8edfe commit fd9b784
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion core/tasks/handler/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,15 @@ func handleMsgEvent(ctx context.Context, rt *runtime.Runtime, event *MsgEvent) e
}
}

msgIn := flows.NewMsgIn(event.MsgUUID, event.URN, channel.ChannelReference(), event.Text, attachments)
// flow will only see the attachments we were able to fetch
availableAttachments := make([]utils.Attachment, 0, len(attachments))
for _, att := range attachments {
if att.ContentType() != utils.UnavailableType {
availableAttachments = append(availableAttachments, att)
}
}

msgIn := flows.NewMsgIn(event.MsgUUID, event.URN, channel.ChannelReference(), event.Text, availableAttachments)
msgIn.SetExternalID(string(event.MsgExternalID))
msgIn.SetID(event.MsgID)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/lib/pq v1.10.7
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.32.2
github.com/nyaruka/goflow v0.174.1
github.com/nyaruka/goflow v0.174.2
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d
github.com/nyaruka/null v1.2.0
github.com/nyaruka/redisx v0.2.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.32.2 h1:SsrVBnccJ9ZcRApAYlyO/lyFG3rREb6d0x2K9Pgtk3s=
github.com/nyaruka/gocommon v1.32.2/go.mod h1:k03R7UY1IX65qPEncv7MgvQx7BZ2laR+ikN1GQjTMbY=
github.com/nyaruka/goflow v0.174.1 h1:nBL6V3MCClIumO2RCuvzVkx5tW1DW1HF1zbfybMXmJI=
github.com/nyaruka/goflow v0.174.1/go.mod h1:rQd2MFaDd/gNtQbaOkaI14ihz3MqsZHmg4H7u1FlQCM=
github.com/nyaruka/goflow v0.174.2 h1:uZf48ng8GepqUr81plbjKeV4GjWYxYSd723nWIKq7PQ=
github.com/nyaruka/goflow v0.174.2/go.mod h1:rQd2MFaDd/gNtQbaOkaI14ihz3MqsZHmg4H7u1FlQCM=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=
Expand Down

0 comments on commit fd9b784

Please sign in to comment.