handlematrix: bridge message edits
This commit is contained in:
@@ -65,6 +65,7 @@ var discordCaps = &event.RoomFeatures{
|
||||
ID: capID(),
|
||||
Reply: event.CapLevelFullySupported,
|
||||
Reaction: event.CapLevelFullySupported,
|
||||
Edit: event.CapLevelFullySupported,
|
||||
Delete: event.CapLevelFullySupported,
|
||||
Formatting: event.FormattingFeatureMap{
|
||||
event.FmtBold: event.CapLevelFullySupported,
|
||||
@@ -137,7 +138,6 @@ var discordCaps = &event.RoomFeatures{
|
||||
LocationMessage: event.CapLevelUnsupported,
|
||||
MaxTextLength: MaxTextLength,
|
||||
// TODO: Support threads.
|
||||
// TODO: Support editing.
|
||||
}
|
||||
|
||||
func (dc *DiscordClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *event.RoomFeatures {
|
||||
|
||||
@@ -18,6 +18,7 @@ package connector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
@@ -72,8 +73,28 @@ func (d *DiscordClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.M
|
||||
}
|
||||
|
||||
func (d *DiscordClient) HandleMatrixEdit(ctx context.Context, msg *bridgev2.MatrixEdit) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
log := zerolog.Ctx(ctx).With().Str("action", "matrix message edit").Logger()
|
||||
ctx = log.WithContext(ctx)
|
||||
|
||||
content, _ := d.connector.MsgConv.ConvertMatrixMessageContent(
|
||||
ctx,
|
||||
msg.Portal,
|
||||
msg.Content,
|
||||
// Disregard link previews for now. Discord generally allows you to
|
||||
// remove individual link previews from a message though.
|
||||
[]string{},
|
||||
)
|
||||
|
||||
_, err := d.Session.ChannelMessageEdit(
|
||||
discordid.ParsePortalID(msg.Portal.ID),
|
||||
discordid.ParseMessageID(msg.EditTarget.ID),
|
||||
content,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send message edit to discord: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DiscordClient) PreHandleMatrixReaction(ctx context.Context, reaction *bridgev2.MatrixReaction) (bridgev2.MatrixReactionPreResponse, error) {
|
||||
|
||||
Reference in New Issue
Block a user