mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Always use fresh admin rank, remembered user rank.
This commit is contained in:
@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
namespace Data {
|
||||
@@ -76,12 +77,24 @@ void ChannelMemberRankChanges::feed(
|
||||
}
|
||||
|
||||
ChannelMemberRankChanges::~ChannelMemberRankChanges() {
|
||||
if (_changes.size() > 1
|
||||
|| (!_changes.empty()
|
||||
&& _changes.front() != _channel->session().userId())) {
|
||||
if (_changes.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto info = _channel->mgInfo.get();
|
||||
auto adminChanges = base::flat_set<UserId>();
|
||||
for (const auto &userId : _changes) {
|
||||
if (info->admins.contains(userId)
|
||||
|| (info->creator
|
||||
&& peerToUser(info->creator->id) == userId)) {
|
||||
adminChanges.emplace(userId);
|
||||
}
|
||||
}
|
||||
if (adminChanges.size() > 1
|
||||
|| (!adminChanges.empty()
|
||||
&& adminChanges.front() != _channel->session().userId())) {
|
||||
if (const auto history
|
||||
= _channel->owner().historyLoaded(_channel)) {
|
||||
history->applyGroupAdminChanges(_changes);
|
||||
history->applyGroupAdminChanges(adminChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2117,6 +2117,15 @@ void HistoryItem::applyEdition(HistoryMessageEdition &&edition) {
|
||||
applyTTL(edition.ttl);
|
||||
setFactcheck(FromMTP(this, edition.mtpFactcheck));
|
||||
|
||||
if (!edition.fromRank.isEmpty()) {
|
||||
if (!Has<HistoryMessageFromRank>()) {
|
||||
AddComponents(HistoryMessageFromRank::Bit());
|
||||
}
|
||||
Get<HistoryMessageFromRank>()->rank = edition.fromRank;
|
||||
} else {
|
||||
RemoveComponents(HistoryMessageFromRank::Bit());
|
||||
}
|
||||
|
||||
finishEdition(keyboardTop);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ HistoryMessageEdition::HistoryMessageEdition(
|
||||
replies = HistoryMessageRepliesData(mtpReplies);
|
||||
}
|
||||
invertMedia = message.is_invert_media();
|
||||
if (const auto rank = message.vfrom_rank()) {
|
||||
fromRank = qs(*rank);
|
||||
}
|
||||
|
||||
const auto period = message.vttl_period();
|
||||
ttl = (period && period->v > 0) ? (message.vdate().v + period->v) : 0;
|
||||
|
||||
@@ -41,4 +41,5 @@ struct HistoryMessageEdition {
|
||||
const MTPMessageMedia *mtpMedia = nullptr;
|
||||
const MTPMessageReactions *mtpReactions = nullptr;
|
||||
const MTPFactCheck *mtpFactcheck = nullptr;
|
||||
QString fromRank;
|
||||
};
|
||||
|
||||
@@ -293,18 +293,16 @@ void Message::refreshRightBadge() {
|
||||
}
|
||||
const auto info = channel->mgInfo.get();
|
||||
const auto userId = peerToUser(user->id);
|
||||
const auto isCreator = (info->creator == user);
|
||||
const auto isAdmin = info->admins.contains(userId);
|
||||
const auto r = info->memberRanks.find(userId);
|
||||
const auto custom = (r != info->memberRanks.end())
|
||||
? r->second
|
||||
: QString();
|
||||
if (!custom.isEmpty()) {
|
||||
return { custom, isAdmin || info->creator == user };
|
||||
}
|
||||
if (info->creator == user) {
|
||||
return { tr::lng_owner_badge(tr::now), true };
|
||||
}
|
||||
if (isAdmin) {
|
||||
if (isCreator || isAdmin) {
|
||||
const auto r = info->memberRanks.find(userId);
|
||||
if (r != info->memberRanks.end() && !r->second.isEmpty()) {
|
||||
return { r->second, true };
|
||||
}
|
||||
if (isCreator) {
|
||||
return { tr::lng_owner_badge(tr::now), true };
|
||||
}
|
||||
return { tr::lng_admin_badge(tr::now), true };
|
||||
}
|
||||
const auto fromRank = item->fromRank();
|
||||
|
||||
Reference in New Issue
Block a user