From bdff86736fb1d45f7cdaa216307bf2e38ca407aa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Mar 2024 18:06:08 +0300 Subject: NewStory: fixes #4301 (invalid reply author's nick in Telegram group chats) --- plugins/NewStory/src/history_array.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 191790475c..6bc1d6e0d2 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -429,16 +429,22 @@ void ItemData::load(bool bLoadAlways) if (MEVENT hReply = db_event_getById(dbe.szModule, dbe.szReplyId)) { DB::EventInfo dbei(hReply); if (dbei) { - CMStringW str; + CMStringW str, wszNick; wchar_t wszTime[100]; TimeZone_PrintTimeStamp(0, dbe.timestamp, L"D t", wszTime, _countof(wszTime), 0); - if (dbei.flags & DBEF_SENT) { + if (Contact::IsGroupChat(hContact) && dbe.szUserId) + wszNick = Utf2T(dbe.szUserId); + else if (dbei.flags & DBEF_SENT) { if (char *szProto = Proto_GetBaseAccountName(hContact)) - str.AppendFormat(L"%s %s %s:\n", wszTime, ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)).get(), TranslateT("wrote")); + wszNick = ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)); + else + wszNick = TranslateT("I"); // shall never happen } - else str.AppendFormat(L"%s %s %s:\n", wszTime, Clist_GetContactDisplayName(hContact, 0), TranslateT("wrote")); + else wszNick = Clist_GetContactDisplayName(hContact, 0); + + str.AppendFormat(L"%s %s %s:\n", wszTime, wszNick.c_str(), TranslateT("wrote")); ptrW wszText(DbEvent_GetTextW(&dbei)); if (mir_wstrlen(wszText) > 43) -- cgit v1.2.3