mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Slightly improved display of media replacement in admin log.
This commit is contained in:
parent
a994c9f017
commit
edcfac8da3
4 changed files with 43 additions and 6 deletions
|
@ -2661,7 +2661,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_admin_log_pinned_message" = "{from} pinned this message:";
|
"lng_admin_log_pinned_message" = "{from} pinned this message:";
|
||||||
"lng_admin_log_unpinned_message" = "{from} unpinned this message";
|
"lng_admin_log_unpinned_message" = "{from} unpinned this message";
|
||||||
"lng_admin_log_edited_caption" = "{from} edited caption:";
|
"lng_admin_log_edited_caption" = "{from} edited caption:";
|
||||||
"lng_admin_log_removed_caption" = "{from} removed caption";
|
"lng_admin_log_edited_media" = "{from} edited media:";
|
||||||
|
"lng_admin_log_edited_media_and_caption" = "{from} edited media and caption:";
|
||||||
|
"lng_admin_log_edited_media_and_removed_caption" = "{from} edited media and removed caption:";
|
||||||
|
"lng_admin_log_removed_caption" = "{from} removed caption:";
|
||||||
"lng_admin_log_previous_caption" = "Original caption";
|
"lng_admin_log_previous_caption" = "Original caption";
|
||||||
"lng_admin_log_edited_message" = "{from} edited this message:";
|
"lng_admin_log_edited_message" = "{from} edited this message:";
|
||||||
"lng_admin_log_previous_message" = "Original message";
|
"lng_admin_log_previous_message" = "Original message";
|
||||||
|
|
|
@ -208,4 +208,8 @@ UpdatedFileReferences GetFileReferences(
|
||||||
return GetFileReferencesHelper(data);
|
return GetFileReferencesHelper(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data) {
|
||||||
|
return GetFileReferencesHelper(data);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -179,4 +179,7 @@ UpdatedFileReferences GetFileReferences(const MTPTheme &data);
|
||||||
UpdatedFileReferences GetFileReferences(
|
UpdatedFileReferences GetFileReferences(
|
||||||
const MTPaccount_SavedRingtones &data);
|
const MTPaccount_SavedRingtones &data);
|
||||||
|
|
||||||
|
// Admin Log Event.
|
||||||
|
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data);
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -136,6 +137,18 @@ bool MediaCanHaveCaption(const MTPMessage &message) {
|
||||||
|| (mediaType == mtpc_messageMediaPhoto);
|
|| (mediaType == mtpc_messageMediaPhoto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 MediaId(const MTPMessage &message) {
|
||||||
|
if (!MediaCanHaveCaption(message)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const auto &media = message.c_message().vmedia();
|
||||||
|
return media
|
||||||
|
? v::match(
|
||||||
|
Data::GetFileReferences(*media).data.begin()->first,
|
||||||
|
[](const auto &d) { return d.id; })
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
|
||||||
TextWithEntities ExtractEditedText(
|
TextWithEntities ExtractEditedText(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const MTPMessage &message) {
|
const MTPMessage &message) {
|
||||||
|
@ -868,22 +881,36 @@ void GenerateItems(
|
||||||
const auto newValue = ExtractEditedText(
|
const auto newValue = ExtractEditedText(
|
||||||
session,
|
session,
|
||||||
action.vnew_message());
|
action.vnew_message());
|
||||||
|
auto oldValue = ExtractEditedText(
|
||||||
|
session,
|
||||||
|
action.vprev_message());
|
||||||
|
|
||||||
const auto canHaveCaption = MediaCanHaveCaption(
|
const auto canHaveCaption = MediaCanHaveCaption(
|
||||||
action.vnew_message());
|
action.vnew_message());
|
||||||
|
const auto changedCaption = (newValue != oldValue);
|
||||||
|
const auto changedMedia = MediaId(action.vnew_message())
|
||||||
|
!= MediaId(action.vprev_message());
|
||||||
|
const auto removedCaption = !oldValue.text.isEmpty()
|
||||||
|
&& newValue.text.isEmpty();
|
||||||
const auto text = (!canHaveCaption
|
const auto text = (!canHaveCaption
|
||||||
? tr::lng_admin_log_edited_message
|
? tr::lng_admin_log_edited_message
|
||||||
: newValue.text.isEmpty()
|
: (changedMedia && removedCaption)
|
||||||
|
? tr::lng_admin_log_edited_media_and_removed_caption
|
||||||
|
: (changedMedia && changedCaption)
|
||||||
|
? tr::lng_admin_log_edited_media_and_caption
|
||||||
|
: changedMedia
|
||||||
|
? tr::lng_admin_log_edited_media
|
||||||
|
: removedCaption
|
||||||
? tr::lng_admin_log_removed_caption
|
? tr::lng_admin_log_removed_caption
|
||||||
: tr::lng_admin_log_edited_caption)(
|
: changedCaption
|
||||||
|
? tr::lng_admin_log_edited_caption
|
||||||
|
: tr::lng_admin_log_edited_message)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_from,
|
lt_from,
|
||||||
fromLinkText,
|
fromLinkText,
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
addSimpleServiceMessage(text);
|
addSimpleServiceMessage(text);
|
||||||
|
|
||||||
auto oldValue = ExtractEditedText(
|
|
||||||
session,
|
|
||||||
action.vprev_message());
|
|
||||||
const auto detachExistingItem = false;
|
const auto detachExistingItem = false;
|
||||||
const auto body = history->createItem(
|
const auto body = history->createItem(
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue