mirror of https://github.com/procxx/kepka.git
Allow editing messages in channels indefinitely.
This commit is contained in:
parent
862e4e45ad
commit
3fa5e004fe
|
@ -406,7 +406,8 @@ bool PeerData::canPinMessages() const {
|
||||||
if (const auto user = asUser()) {
|
if (const auto user = asUser()) {
|
||||||
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
|
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
|
||||||
} else if (const auto chat = asChat()) {
|
} else if (const auto chat = asChat()) {
|
||||||
return chat->amIn() && !chat->amRestricted(ChatRestriction::f_pin_messages);
|
return chat->amIn()
|
||||||
|
&& !chat->amRestricted(ChatRestriction::f_pin_messages);
|
||||||
} else if (const auto channel = asChannel()) {
|
} else if (const auto channel = asChannel()) {
|
||||||
return channel->isMegagroup()
|
return channel->isMegagroup()
|
||||||
? !channel->amRestricted(ChatRestriction::f_pin_messages)
|
? !channel->amRestricted(ChatRestriction::f_pin_messages)
|
||||||
|
@ -416,6 +417,19 @@ bool PeerData::canPinMessages() const {
|
||||||
Unexpected("Peer type in PeerData::canPinMessages.");
|
Unexpected("Peer type in PeerData::canPinMessages.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PeerData::canEditMessagesIndefinitely() const {
|
||||||
|
if (const auto user = asUser()) {
|
||||||
|
return user->isSelf();
|
||||||
|
} else if (const auto chat = asChat()) {
|
||||||
|
return false;
|
||||||
|
} else if (const auto channel = asChannel()) {
|
||||||
|
return channel->isMegagroup()
|
||||||
|
? channel->canPinMessages()
|
||||||
|
: channel->canEditMessages();
|
||||||
|
}
|
||||||
|
Unexpected("Peer type in PeerData::canEditMessagesIndefinitely.");
|
||||||
|
}
|
||||||
|
|
||||||
void PeerData::setPinnedMessageId(MsgId messageId) {
|
void PeerData::setPinnedMessageId(MsgId messageId) {
|
||||||
const auto min = [&] {
|
const auto min = [&] {
|
||||||
if (const auto channel = asChannel()) {
|
if (const auto channel = asChannel()) {
|
||||||
|
|
|
@ -297,6 +297,7 @@ public:
|
||||||
[[nodiscard]] ImagePtr currentUserpic() const;
|
[[nodiscard]] ImagePtr currentUserpic() const;
|
||||||
|
|
||||||
[[nodiscard]] bool canPinMessages() const;
|
[[nodiscard]] bool canPinMessages() const;
|
||||||
|
[[nodiscard]] bool canEditMessagesIndefinitely() const;
|
||||||
[[nodiscard]] MsgId pinnedMessageId() const {
|
[[nodiscard]] MsgId pinnedMessageId() const {
|
||||||
return _pinnedMessageId;
|
return _pinnedMessageId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -768,15 +768,8 @@ bool HistoryMessage::allowsSendNow() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::isTooOldForEdit(TimeId now) const {
|
bool HistoryMessage::isTooOldForEdit(TimeId now) const {
|
||||||
const auto peer = _history->peer;
|
return !_history->peer->canEditMessagesIndefinitely()
|
||||||
if (peer->isSelf()) {
|
&& (now - date() >= Global::EditTimeLimit());
|
||||||
return false;
|
|
||||||
} else if (const auto megagroup = peer->asMegagroup()) {
|
|
||||||
if (megagroup->canPinMessages()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (now - date() >= Global::EditTimeLimit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::allowsEdit(TimeId now) const {
|
bool HistoryMessage::allowsEdit(TimeId now) const {
|
||||||
|
|
|
@ -6831,12 +6831,9 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int
|
||||||
p.setFont(st::msgServiceNameFont);
|
p.setFont(st::msgServiceNameFont);
|
||||||
p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), tr::lng_edit_message(tr::now));
|
p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), tr::lng_edit_message(tr::now));
|
||||||
|
|
||||||
if (!_replyEditMsg || _replyEditMsg->history()->peer->isSelf()) return;
|
if (!_replyEditMsg
|
||||||
|
|| _replyEditMsg->history()->peer->canEditMessagesIndefinitely()) {
|
||||||
if (const auto megagroup = _replyEditMsg->history()->peer->asMegagroup()) {
|
return;
|
||||||
if (megagroup->amCreator() || megagroup->hasAdminRights()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString editTimeLeftText;
|
QString editTimeLeftText;
|
||||||
|
|
Loading…
Reference in New Issue