client: support TG -> Matrix disappearing messages
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
@@ -154,6 +154,7 @@ type GhostMetadata struct {
|
|||||||
type PortalMetadata struct {
|
type PortalMetadata struct {
|
||||||
IsSuperGroup bool `json:"is_supergroup,omitempty"`
|
IsSuperGroup bool `json:"is_supergroup,omitempty"`
|
||||||
ReadUpTo int `json:"read_up_to,omitempty"`
|
ReadUpTo int `json:"read_up_to,omitempty"`
|
||||||
|
MessagesTTL int `json:"messages_ttl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageMetadata struct {
|
type MessageMetadata struct {
|
||||||
|
|||||||
@@ -262,7 +262,18 @@ func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, channels map[in
|
|||||||
// case *tg.MessageActionGeoProximityReached:
|
// case *tg.MessageActionGeoProximityReached:
|
||||||
// case *tg.MessageActionGroupCall:
|
// case *tg.MessageActionGroupCall:
|
||||||
// case *tg.MessageActionInviteToGroupCall:
|
// 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.MessageActionGroupCallScheduled:
|
||||||
// case *tg.MessageActionSetChatTheme:
|
// case *tg.MessageActionSetChatTheme:
|
||||||
// case *tg.MessageActionChatJoinedByRequest:
|
// case *tg.MessageActionChatJoinedByRequest:
|
||||||
|
|||||||
@@ -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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user