Skip to content

Commit

Permalink
Use downloadUrl for attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Nov 13, 2023
1 parent 3f7e7bc commit 2deeed9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions handlers/teams/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w h
attachmentURLs := make([]string, 0, 2)

for _, att := range payload.Attachments {
if att.ContentType != "" && att.ContentUrl != "" {
attachmentURLs = append(attachmentURLs, att.ContentUrl)
if att.ContentType != "" && att.Content.DownloadUrl != "" {
attachmentURLs = append(attachmentURLs, att.Content.DownloadUrl)
}
}

Expand Down Expand Up @@ -339,6 +339,11 @@ type Attachment struct {
ContentType string `json:"contentType"`
ContentUrl string `json:"contentUrl"`
Name string `json:"name,omitempty"`
Content struct {
DownloadUrl string `json:"downloadUrl,omitempty"`
UniqueId string `json:"uniqueId,omitempty"`
FileType string `json:"fileType,omitempty"`
} `json:"content,omitempty"`
}

type CardAction struct {
Expand Down Expand Up @@ -390,7 +395,11 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat
if err != nil {
logrus.WithField("channel_uuid", msg.Channel().UUID().String()).WithError(err).Error("Error while parsing the media URL")
}
payload.Attachments = append(payload.Attachments, Attachment{attType, attURL, filename})
payload.Attachments = append(payload.Attachments, Attachment{attType, attURL, filename, struct {
DownloadUrl string "json:\"downloadUrl,omitempty\""
UniqueId string "json:\"uniqueId,omitempty\""
FileType string "json:\"fileType,omitempty\""
}{}})
}

if msg.Text() != "" {
Expand Down

0 comments on commit 2deeed9

Please sign in to comment.