@@ -13,8 +13,9 @@ import (
13
13
)
14
14
15
15
var (
16
- _ bridgev2.EditHandlingNetworkAPI = (* GChatClient )(nil )
17
- _ bridgev2.ReactionHandlingNetworkAPI = (* GChatClient )(nil )
16
+ _ bridgev2.EditHandlingNetworkAPI = (* GChatClient )(nil )
17
+ _ bridgev2.ReactionHandlingNetworkAPI = (* GChatClient )(nil )
18
+ _ bridgev2.RedactionHandlingNetworkAPI = (* GChatClient )(nil )
18
19
)
19
20
20
21
func portalToGroupId (portal * bridgev2.Portal ) (* proto.GroupId , error ) {
@@ -72,17 +73,7 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
72
73
topicId = string (msg .ThreadRoot .ID )
73
74
}
74
75
messageInfo .ReplyTo = & proto.SendReplyTarget {
75
- Id : & proto.MessageId {
76
- ParentId : & proto.MessageParentId {
77
- Parent : & proto.MessageParentId_TopicId {
78
- TopicId : & proto.TopicId {
79
- GroupId : groupId ,
80
- TopicId : topicId ,
81
- },
82
- },
83
- },
84
- MessageId : replyToId ,
85
- },
76
+ Id : c .makeMessageId (msg .Portal , topicId , replyToId ),
86
77
CreateTime : msg .ReplyTo .Timestamp .UnixMicro (),
87
78
}
88
79
}
@@ -146,30 +137,15 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
146
137
}
147
138
148
139
func (c * GChatClient ) HandleMatrixEdit (ctx context.Context , msg * bridgev2.MatrixEdit ) error {
149
- groupId , err := portalToGroupId (msg .Portal )
150
- if err != nil {
151
- return err
152
- }
153
-
154
140
text , entities := c .msgConv .ToGChat (ctx , msg .Content )
155
141
msgId := string (msg .EditTarget .ID )
156
142
threadId := string (msg .EditTarget .ThreadRoot )
157
143
topicId := msgId
158
144
if threadId != "" {
159
145
topicId = threadId
160
146
}
161
- res , err := c .client .EditMessage (ctx , & proto.EditMessageRequest {
162
- MessageId : & proto.MessageId {
163
- ParentId : & proto.MessageParentId {
164
- Parent : & proto.MessageParentId_TopicId {
165
- TopicId : & proto.TopicId {
166
- GroupId : groupId ,
167
- TopicId : topicId ,
168
- },
169
- },
170
- },
171
- MessageId : msgId ,
172
- },
147
+ _ , err := c .client .EditMessage (ctx , & proto.EditMessageRequest {
148
+ MessageId : c .makeMessageId (msg .Portal , topicId , msgId ),
173
149
TextBody : text ,
174
150
Annotations : entities ,
175
151
MessageInfo : & proto.MessageInfo {
@@ -179,7 +155,22 @@ func (c *GChatClient) HandleMatrixEdit(ctx context.Context, msg *bridgev2.Matrix
179
155
if err != nil {
180
156
return err
181
157
}
182
- _ = res
158
+ return nil
159
+ }
160
+
161
+ func (c * GChatClient ) HandleMatrixMessageRemove (ctx context.Context , msg * bridgev2.MatrixMessageRemove ) error {
162
+ msgId := string (msg .TargetMessage .ID )
163
+ threadId := string (msg .TargetMessage .ThreadRoot )
164
+ topicId := msgId
165
+ if threadId != "" {
166
+ topicId = threadId
167
+ }
168
+ _ , err := c .client .DeleteMessage (ctx , & proto.DeleteMessageRequest {
169
+ MessageId : c .makeMessageId (msg .Portal , topicId , msgId ),
170
+ })
171
+ if err != nil {
172
+ return err
173
+ }
183
174
return nil
184
175
}
185
176
@@ -213,26 +204,11 @@ func (c *GChatClient) HandleMatrixReactionRemove(ctx context.Context, msg *bridg
213
204
}
214
205
215
206
func (c * GChatClient ) doHandleMatrixReaction (ctx context.Context , portal * bridgev2.Portal , topicId , messageId , emoji string , typ proto.UpdateReactionRequest_ReactionUpdateType ) error {
216
- groupId , err := portalToGroupId (portal )
217
- if err != nil {
218
- return err
219
- }
220
-
221
207
if topicId == "" {
222
208
topicId = messageId
223
209
}
224
- _ , err = c .client .UpdateReaction (ctx , & proto.UpdateReactionRequest {
225
- MessageId : & proto.MessageId {
226
- ParentId : & proto.MessageParentId {
227
- Parent : & proto.MessageParentId_TopicId {
228
- TopicId : & proto.TopicId {
229
- GroupId : groupId ,
230
- TopicId : topicId ,
231
- },
232
- },
233
- },
234
- MessageId : messageId ,
235
- },
210
+ _ , err := c .client .UpdateReaction (ctx , & proto.UpdateReactionRequest {
211
+ MessageId : c .makeMessageId (portal , topicId , messageId ),
236
212
Emoji : & proto.Emoji {
237
213
Content : & proto.Emoji_Unicode {
238
214
Unicode : emoji ,
0 commit comments