handlematrix: bridge outgoing reactions

This commit is contained in:
Skip R
2025-12-17 18:44:52 -08:00
parent 2cacd4ec81
commit e030c9548c
2 changed files with 28 additions and 11 deletions

View File

@@ -55,8 +55,9 @@ func capID() string {
} }
var discordCaps = &event.RoomFeatures{ var discordCaps = &event.RoomFeatures{
ID: capID(), ID: capID(),
Reply: event.CapLevelFullySupported, Reply: event.CapLevelFullySupported,
Reaction: event.CapLevelFullySupported,
Formatting: event.FormattingFeatureMap{ Formatting: event.FormattingFeatureMap{
event.FmtBold: event.CapLevelFullySupported, event.FmtBold: event.CapLevelFullySupported,
event.FmtItalic: event.CapLevelFullySupported, event.FmtItalic: event.CapLevelFullySupported,

View File

@@ -73,19 +73,35 @@ func (d *DiscordClient) HandleMatrixEdit(ctx context.Context, msg *bridgev2.Matr
panic("implement me") panic("implement me")
} }
func (d *DiscordClient) PreHandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (bridgev2.MatrixReactionPreResponse, error) { func (d *DiscordClient) PreHandleMatrixReaction(ctx context.Context, reaction *bridgev2.MatrixReaction) (bridgev2.MatrixReactionPreResponse, error) {
//TODO implement me key := reaction.Content.RelatesTo.Key
panic("implement me") // TODO: Handle custom emoji.
return bridgev2.MatrixReactionPreResponse{
SenderID: networkid.UserID(d.UserLogin.ID),
EmojiID: networkid.EmojiID(key),
}, nil
} }
func (d *DiscordClient) HandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (reaction *database.Reaction, err error) { func (d *DiscordClient) HandleMatrixReaction(ctx context.Context, reaction *bridgev2.MatrixReaction) (*database.Reaction, error) {
//TODO implement me key := reaction.Content.RelatesTo.Key
panic("implement me") portal := reaction.Portal
// TODO: Support guilds.
guildID := ""
err := d.Session.MessageReactionAddUser(guildID, string(portal.ID), string(reaction.TargetMessage.ID), key)
return nil, err
} }
func (d *DiscordClient) HandleMatrixReactionRemove(ctx context.Context, msg *bridgev2.MatrixReactionRemove) error { func (d *DiscordClient) HandleMatrixReactionRemove(ctx context.Context, removal *bridgev2.MatrixReactionRemove) error {
//TODO implement me removing := removal.TargetReaction
panic("implement me") emojiID := removing.EmojiID
channelID := string(removing.Room.ID)
// TODO: Support guilds.
guildID := ""
err := d.Session.MessageReactionRemoveUser(guildID, channelID, string(removing.MessageID), string(emojiID), string(d.UserLogin.ID))
return err
} }
func (d *DiscordClient) HandleMatrixMessageRemove(ctx context.Context, msg *bridgev2.MatrixMessageRemove) error { func (d *DiscordClient) HandleMatrixMessageRemove(ctx context.Context, msg *bridgev2.MatrixMessageRemove) error {