diff --git a/pkg/connector/config.go b/pkg/connector/config.go index ed150061..54090ce4 100644 --- a/pkg/connector/config.go +++ b/pkg/connector/config.go @@ -154,6 +154,7 @@ type GhostMetadata struct { type PortalMetadata struct { IsSuperGroup bool `json:"is_supergroup,omitempty"` ReadUpTo int `json:"read_up_to,omitempty"` + MessagesTTL int `json:"messages_ttl,omitempty"` } type MessageMetadata struct { diff --git a/pkg/connector/telegram.go b/pkg/connector/telegram.go index 76d58221..d6b2d64f 100644 --- a/pkg/connector/telegram.go +++ b/pkg/connector/telegram.go @@ -262,7 +262,18 @@ func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, channels map[in // case *tg.MessageActionGeoProximityReached: // case *tg.MessageActionGroupCall: // case *tg.MessageActionInviteToGroupCall: - // case *tg.MessageActionSetMessagesTTL: + case *tg.MessageActionSetMessagesTTL: + eventMeta.Type = bridgev2.RemoteEventChatResync + t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.ChatResync{ + EventMeta: eventMeta, + ChatInfo: &bridgev2.ChatInfo{ + ExtraUpdates: func(ctx context.Context, p *bridgev2.Portal) bool { + updated := p.Portal.Metadata.(*PortalMetadata).MessagesTTL != action.Period + p.Portal.Metadata.(*PortalMetadata).MessagesTTL = action.Period + return updated + }, + }, + }) // case *tg.MessageActionGroupCallScheduled: // case *tg.MessageActionSetChatTheme: // case *tg.MessageActionChatJoinedByRequest: diff --git a/pkg/connector/tomatrix.go b/pkg/connector/tomatrix.go index c4567292..8837157d 100644 --- a/pkg/connector/tomatrix.go +++ b/pkg/connector/tomatrix.go @@ -166,6 +166,22 @@ func (c *TelegramClient) convertToMatrix(ctx context.Context, portal *bridgev2.P } } + if disappearingSetting == nil { + // The TTL is either included in the message, or it's on the portal's + // metadata. + if ttl, ok := msg.GetTTLPeriod(); ok { + cm.Disappear = database.DisappearingSetting{ + Type: database.DisappearingTypeAfterSend, + Timer: time.Duration(ttl) * time.Second, + } + } else if portal.Metadata.(*PortalMetadata).MessagesTTL > 0 { + cm.Disappear = database.DisappearingSetting{ + Type: database.DisappearingTypeAfterSend, + Timer: time.Duration(ttl) * time.Second, + } + } + } + return }