Better setChatMemberStatus.
GitOrigin-RevId: eda67ca9fc959c9b94184ca952af8186aaf8d2de
This commit is contained in:
parent
9f7b5fe258
commit
da8d4ceab1
@ -4338,7 +4338,20 @@ void ContactsManager::change_channel_participant_status_impl(ChannelId channel_i
|
|||||||
} else if (status.is_administrator()) {
|
} else if (status.is_administrator()) {
|
||||||
need_promote = true;
|
need_promote = true;
|
||||||
} else if (!status.is_member() || status.is_restricted()) {
|
} else if (!status.is_member() || status.is_restricted()) {
|
||||||
need_restrict = true;
|
if (status.is_member() && !old_status.is_member()) {
|
||||||
|
// TODO there is no way in server API to invite someone and change restrictions
|
||||||
|
// we need to first add user and change restrictions again after that
|
||||||
|
// but if restrictions aren't changed, then adding is enough
|
||||||
|
auto copy_old_status = old_status;
|
||||||
|
copy_old_status.set_is_member(true);
|
||||||
|
if (copy_old_status == status) {
|
||||||
|
need_add = true;
|
||||||
|
} else {
|
||||||
|
need_restrict = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
need_restrict = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// regular member
|
// regular member
|
||||||
if (old_status.is_administrator()) {
|
if (old_status.is_administrator()) {
|
||||||
|
@ -166,6 +166,14 @@ class DialogParticipantStatus {
|
|||||||
return (flags_ & CAN_ADD_WEB_PAGE_PREVIEWS) != 0;
|
return (flags_ & CAN_ADD_WEB_PAGE_PREVIEWS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_is_member(bool is_member) {
|
||||||
|
if (is_member) {
|
||||||
|
flags_ |= IS_MEMBER;
|
||||||
|
} else {
|
||||||
|
flags_ &= ~IS_MEMBER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool is_member() const {
|
bool is_member() const {
|
||||||
return (flags_ & IS_MEMBER) != 0;
|
return (flags_ & IS_MEMBER) != 0;
|
||||||
}
|
}
|
||||||
|
@ -3150,10 +3150,13 @@ class CliClient final : public Actor {
|
|||||||
status = make_tl_object<td_api::chatMemberStatusAdministrator>(true, false, false, false, false, false, false,
|
status = make_tl_object<td_api::chatMemberStatusAdministrator>(true, false, false, false, false, false, false,
|
||||||
false, false);
|
false, false);
|
||||||
} else if (status_str == "rest") {
|
} else if (status_str == "rest") {
|
||||||
status = make_tl_object<td_api::chatMemberStatusRestricted>(true, static_cast<int32>(60 + std::time(nullptr)),
|
status = make_tl_object<td_api::chatMemberStatusRestricted>(true, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
false, false, false, false);
|
false, false, false, false);
|
||||||
} else if (status_str == "restkick") {
|
} else if (status_str == "restkick") {
|
||||||
status = make_tl_object<td_api::chatMemberStatusRestricted>(false, static_cast<int32>(60 + std::time(nullptr)),
|
status = make_tl_object<td_api::chatMemberStatusRestricted>(false, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
|
true, false, false, false);
|
||||||
|
} else if (status_str == "restunkick") {
|
||||||
|
status = make_tl_object<td_api::chatMemberStatusRestricted>(true, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
true, false, false, false);
|
true, false, false, false);
|
||||||
} else if (status_str == "unrest") {
|
} else if (status_str == "unrest") {
|
||||||
status = make_tl_object<td_api::chatMemberStatusRestricted>(true, 0, true, true, true, true);
|
status = make_tl_object<td_api::chatMemberStatusRestricted>(true, 0, true, true, true, true);
|
||||||
|
Reference in New Issue
Block a user