Skip to content

Commit

Permalink
+ location support for directly published messages
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Nov 21, 2023
1 parent 4ba99a6 commit c6e276f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion service/chats/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Reader interface {
const ReaderTtl = 24 * time.Hour
const readBatchSize = 16
const msgFmtReadOnceFailed = "unexpected failure: %s\ndon't worry, retrying in %s..."
const msgFmtRunFatal = "fatal: %s,\nto recover: try to select a subscription again"
const msgFmtRunFatal = " %s,\nℹ please select a subscription to read again"
const backOffInit = 1 * time.Second
const backOffFactor = 3
const backOffMax = 24 * time.Hour
Expand Down
13 changes: 13 additions & 0 deletions service/messages/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const attrKeyFileMediaDuration = "tgfilemediaduration"
const attrKeyFileImgHeight = "tgfileimgheight"
const attrKeyFileImgWidth = "tgfileimgwidth"
const attrKeyFileType = "tgfiletype"
const attrKeyLatitude = "latitude"
const attrKeyLongitude = "longitude"

type FileType int32

Expand Down Expand Up @@ -132,6 +134,17 @@ func toCloudEvent(msg *telebot.Message, txt string, evt *pb.CloudEvent) (err err
},
}
f = msg.Document.File
case msg.Location != nil:
evt.Attributes[attrKeyLatitude] = &pb.CloudEventAttributeValue{
Attr: &pb.CloudEventAttributeValue_CeString{
CeString: fmt.Sprintf("%f", msg.Location.Lat),
},
}
evt.Attributes[attrKeyLongitude] = &pb.CloudEventAttributeValue{
Attr: &pb.CloudEventAttributeValue_CeString{
CeString: fmt.Sprintf("%f", msg.Location.Lng),
},
}
case msg.Photo != nil:
evt.Attributes[attrKeyFileType] = &pb.CloudEventAttributeValue{
Attr: &pb.CloudEventAttributeValue_CeInteger{
Expand Down

0 comments on commit c6e276f

Please sign in to comment.