Skip to content

Commit

Permalink
Add support for sending captions and fix some fields in send requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 16, 2024
1 parent d0a8b84 commit 1d3ef74
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libgm/gmproto/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified libgm/gmproto/client.pb.raw
Binary file not shown.
2 changes: 1 addition & 1 deletion libgm/gmproto/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ message SendMessageRequest {
MessagePayload messagePayload = 3;
settings.SIMPayload SIMPayload = 4;
string tmpID = 5;
bool isReply = 6; // not sure
bool isRCS = 6; // not sure
ReplyPayload reply = 8;
}

Expand Down
8 changes: 8 additions & 0 deletions libgm/gmproto/conversations.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified libgm/gmproto/conversations.pb.raw
Binary file not shown.
1 change: 1 addition & 0 deletions libgm/gmproto/conversations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ message MediaContent {
string mediaID2 = 9;
bytes decryptionKey = 11;
bytes decryptionKey2 = 12;
string mimeType = 14;
}

message Dimensions {
Expand Down
1 change: 1 addition & 0 deletions libgm/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (c *Client) UploadMedia(data []byte, fileName, mime string) (*gmproto.Media
MediaName: fileName,
Size: int64(len(data)),
DecryptionKey: decryptionKey,
MimeType: mime,
}, nil
}

Expand Down
9 changes: 8 additions & 1 deletion portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1932,10 +1932,10 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co
} else if replyToMsg == nil {
log.Warn().Str("reply_to_mxid", replyToMXID.String()).Msg("Reply target message not found")
} else {
req.IsReply = true
req.Reply = &gmproto.ReplyPayload{MessageID: replyToMsg.ID}
}
}
req.IsRCS = portal.Type == gmproto.ConversationType_RCS

switch content.MsgType {
case event.MsgText, event.MsgEmote, event.MsgNotice:
Expand All @@ -1956,6 +1956,13 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co
req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{
Data: &gmproto.MessageInfo_MediaContent{MediaContent: resp},
}}
if content.FileName != "" && content.FileName != content.Body {
req.MessagePayload.MessageInfo = append(req.MessagePayload.MessageInfo, &gmproto.MessageInfo{
Data: &gmproto.MessageInfo_MessageContent{MessageContent: &gmproto.MessageContent{
Content: content.Body,
}},
})
}
case event.MsgBeeperGallery:
for i, part := range content.BeeperGalleryImages {
convertedPart, err := portal.reuploadMedia(ctx, sender, part, nil)
Expand Down

0 comments on commit 1d3ef74

Please sign in to comment.