mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/networkinterface: add DeleteOnlyForMe field to message remove events
Some checks failed
Some checks failed
This commit is contained in:
parent
5d916e0e9a
commit
7a5f15b03c
3 changed files with 20 additions and 2 deletions
|
|
@ -913,11 +913,15 @@ type RemoteBackfill interface {
|
|||
GetBackfillData(ctx context.Context, portal *Portal) (*FetchMessagesResponse, error)
|
||||
}
|
||||
|
||||
type RemoteChatDelete interface {
|
||||
type RemoteDeleteOnlyForMe interface {
|
||||
RemoteEvent
|
||||
DeleteOnlyForMe() bool
|
||||
}
|
||||
|
||||
type RemoteChatDelete interface {
|
||||
RemoteDeleteOnlyForMe
|
||||
}
|
||||
|
||||
type RemoteEventThatMayCreatePortal interface {
|
||||
RemoteEvent
|
||||
ShouldCreatePortal() bool
|
||||
|
|
|
|||
|
|
@ -2370,6 +2370,12 @@ func (portal *Portal) handleRemoteMessageRemove(ctx context.Context, source *Use
|
|||
log.Debug().Msg("Target message not found")
|
||||
return
|
||||
}
|
||||
onlyForMeProvider, ok := evt.(RemoteDeleteOnlyForMe)
|
||||
onlyForMe := ok && onlyForMeProvider.DeleteOnlyForMe()
|
||||
if onlyForMe && portal.Receiver == "" {
|
||||
// TODO check if there are other user logins before deleting
|
||||
}
|
||||
|
||||
intent := portal.GetIntentFor(ctx, evt.GetSender(), source, RemoteEventMessageRemove)
|
||||
if intent == portal.Bridge.Bot && len(targetParts) > 0 {
|
||||
senderIntent, err := portal.getIntentForMXID(ctx, targetParts[0].SenderMXID)
|
||||
|
|
|
|||
|
|
@ -63,10 +63,18 @@ type MessageRemove struct {
|
|||
EventMeta
|
||||
|
||||
TargetMessage networkid.MessageID
|
||||
OnlyForMe bool
|
||||
}
|
||||
|
||||
var _ bridgev2.RemoteMessageRemove = (*MessageRemove)(nil)
|
||||
var (
|
||||
_ bridgev2.RemoteMessageRemove = (*MessageRemove)(nil)
|
||||
_ bridgev2.RemoteDeleteOnlyForMe = (*MessageRemove)(nil)
|
||||
)
|
||||
|
||||
func (evt *MessageRemove) GetTargetMessage() networkid.MessageID {
|
||||
return evt.TargetMessage
|
||||
}
|
||||
|
||||
func (evt *MessageRemove) DeleteOnlyForMe() bool {
|
||||
return evt.OnlyForMe
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue