Skip to content

Commit

Permalink
add reaction removal
Browse files Browse the repository at this point in the history
  • Loading branch information
JJTech0130 committed Jul 17, 2024
1 parent 3928693 commit d07ae93
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ func (m *MetaClient) handleTable(ctx context.Context, tbl *table.LSTable) {
}
for _, msg := range insert {
log.Trace().Int64("thread_id", msg.ThreadKey).Str("message_id", msg.MessageId).Msg("InsertMessage")
//converted := m.messageConverter.ToMatrix(ctx, msg)
//log.Trace().Any("converted", converted).Msg("Converted message")
m.insertMessage(ctx, msg)
}

Expand All @@ -265,18 +263,32 @@ func (m *MetaClient) handleTable(ctx context.Context, tbl *table.LSTable) {
LogContext: func(c zerolog.Context) zerolog.Context {
return c.
Any("reaction", reaction.Reaction).
//Str("sender_id", string(id)).
Str("message_id", string(reaction.MessageId))
},
Sender: m.senderFromID(reaction.ActorId),
PortalKey: networkid.PortalKey{ID: networkid.PortalID(strconv.Itoa(int(reaction.ThreadKey)))},
TargetMessage: networkid.MessageID(reaction.MessageId),
EmojiID: networkid.EmojiID(reaction.Reaction),
Emoji: reaction.Reaction,
// only 1 reaction can be used per message, so just use a hardcoded ID
EmojiID: networkid.EmojiID("reaction"),
Emoji: reaction.Reaction,
}
m.Main.Bridge.QueueRemoteEvent(m.login, evt)
}

for _, reaction := range tbl.LSDeleteReaction {
log.Warn().Str("message_id", reaction.MessageId).Msg("LSDeleteReaction")

evt := &bridgev2.SimpleRemoteEvent[any]{
Type: bridgev2.RemoteEventReactionRemove,
LogContext: func(c zerolog.Context) zerolog.Context {
return c.
Str("message_id", string(reaction.MessageId))
},
Sender: m.senderFromID(reaction.ActorId),
PortalKey: networkid.PortalKey{ID: networkid.PortalID(strconv.Itoa(int(reaction.ThreadKey)))},
TargetMessage: networkid.MessageID(reaction.MessageId),
EmojiID: networkid.EmojiID("reaction"),
}
// if timestamp != nil {
// evt.Timestamp = *timestamp
// }
m.Main.Bridge.QueueRemoteEvent(m.login, evt)
}
}
Expand Down

0 comments on commit d07ae93

Please sign in to comment.