bridgev2/networkinterface: add DeleteOnlyForMe field to message remove events
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This commit is contained in:
Tulir Asokan 2024-09-26 12:16:54 +03:00
commit 7a5f15b03c
3 changed files with 20 additions and 2 deletions

View file

@ -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

View file

@ -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)

View file

@ -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
}