From e976165e6cd32c2db87a21a46605aac6fcb6896d Mon Sep 17 00:00:00 2001 From: mytelegram Date: Fri, 3 Jan 2025 21:29:33 +0800 Subject: [PATCH] fix: Forward messages --- .../MessageDomainEventHandler.cs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/source/src/MyTelegram.Messenger.QueryServer/DomainEventHandlers/MessageDomainEventHandler.cs b/source/src/MyTelegram.Messenger.QueryServer/DomainEventHandlers/MessageDomainEventHandler.cs index 759d084e..6f4b0c48 100644 --- a/source/src/MyTelegram.Messenger.QueryServer/DomainEventHandlers/MessageDomainEventHandler.cs +++ b/source/src/MyTelegram.Messenger.QueryServer/DomainEventHandlers/MessageDomainEventHandler.cs @@ -234,16 +234,34 @@ await PushUpdatesToPeerAsync(item.OwnerPeer, } } - private Task HandleForwardMessageAsync(ReceiveInboxMessageCompletedSagaEvent aggregateEvent) + private async Task HandleForwardMessageAsync(ReceiveInboxMessageCompletedSagaEvent aggregateEvent) { var item = aggregateEvent.MessageItem; var updates = updatesLayeredService.Converter.ToInboxForwardMessageUpdates(aggregateEvent); - var layeredData = updatesLayeredService.GetLayeredData(c => c.ToInboxForwardMessageUpdates(aggregateEvent)); - return PushUpdatesToPeerAsync(item.OwnerPeer, + if (aggregateEvent.MessageItem.FwdHeader?.FromId.PeerType == PeerType.Channel) + { + if (updates is TUpdates tUpdates) + { + var channelId = aggregateEvent.MessageItem.FwdHeader.FromId.PeerId; + var channelReadModel = await channelAppService.GetAsync(channelId); + var photoReadModel = channelReadModel.PhotoId.HasValue + ? await photoAppService.GetAsync(channelReadModel.PhotoId.Value) + : null; + + var channel = chatLayeredService.Converter.ToChannel( + 0, + channelReadModel, + photoReadModel, + null, + false); + tUpdates.Chats.Add(channel); + } + } + + await PushUpdatesToPeerAsync(item.OwnerPeer, updates, - pts: item.Pts, - layeredData: layeredData); + pts: item.Pts); } private async Task HandleInviteToChannelAsync(SendOutboxMessageCompletedSagaEvent aggregateEvent)