tomatrix: use channel ghost if portal not found
This commit is contained in:
@@ -922,7 +922,8 @@ func (t *TelegramClient) onUpdate(ctx context.Context, e tg.Entities, upd tg.Upd
|
|||||||
zerolog.Ctx(ctx).Trace().Stringer("channel", channel).Msg("Raw channel info in update")
|
zerolog.Ctx(ctx).Trace().Stringer("channel", channel).Msg("Raw channel info in update")
|
||||||
if channel.GetLeft() {
|
if channel.GetLeft() {
|
||||||
t.selfLeaveChat(ctx, t.makePortalKeyFromID(ids.PeerTypeChannel, channel.ID, 0), fmt.Errorf("left flag in entity update"))
|
t.selfLeaveChat(ctx, t.makePortalKeyFromID(ids.PeerTypeChannel, channel.ID, 0), fmt.Errorf("left flag in entity update"))
|
||||||
} else if _, err := t.updateChannel(ctx, channel); err != nil {
|
}
|
||||||
|
if _, err := t.updateChannel(ctx, channel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,8 +273,10 @@ func (t *TelegramClient) addForwardHeader(ctx context.Context, part *bridgev2.Co
|
|||||||
)
|
)
|
||||||
case *tg.PeerChannel, *tg.PeerChat:
|
case *tg.PeerChannel, *tg.PeerChat:
|
||||||
unknownType := "unknown chat"
|
unknownType := "unknown chat"
|
||||||
if _, ok := from.(*tg.PeerChannel); ok {
|
var channelID int64
|
||||||
|
if ch, ok := from.(*tg.PeerChannel); ok {
|
||||||
unknownType = "unknown channel"
|
unknownType = "unknown channel"
|
||||||
|
channelID = ch.ChannelID
|
||||||
}
|
}
|
||||||
portal, err := t.main.Bridge.GetExistingPortalByKey(ctx, t.makePortalKeyFromPeer(from, 0))
|
portal, err := t.main.Bridge.GetExistingPortalByKey(ctx, t.makePortalKeyFromPeer(from, 0))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -293,6 +295,19 @@ func (t *TelegramClient) addForwardHeader(ctx context.Context, part *bridgev2.Co
|
|||||||
fwdFromText = unknownType
|
fwdFromText = unknownType
|
||||||
fwdFromHTML = unknownType
|
fwdFromHTML = unknownType
|
||||||
}
|
}
|
||||||
|
if channelID != 0 && fwdFromText == unknownType {
|
||||||
|
ghost, err := t.main.Bridge.GetExistingGhostByID(ctx, ids.MakeChannelUserID(channelID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if ghost != nil && ghost.Name != "" {
|
||||||
|
fwdFromText = ghost.Name
|
||||||
|
fwdFromHTML = fmt.Sprintf(
|
||||||
|
`<a href="%s">%s</a>`,
|
||||||
|
ghost.Intent.GetMXID().URI().MatrixToURL(),
|
||||||
|
html.EscapeString(fwdFromText),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO fetch channel if not found
|
// TODO fetch channel if not found
|
||||||
}
|
}
|
||||||
if fwdFromText == "" && fwd.FromName != "" {
|
if fwdFromText == "" && fwd.FromName != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user