can_set_username bit support added

This commit is contained in:
John Preston 2016-03-11 18:21:05 +03:00
parent 02b0512761
commit 0913833f6c
4 changed files with 20 additions and 11 deletions

View File

@ -944,7 +944,10 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
_checkRequestId = 0;
QString err(error.type());
if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") {
if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
Ui::hideLayer();
return true;
} else if (err == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
if (_existing) {
Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else {
@ -953,11 +956,11 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
onPrivacyChange();
}
return true;
} else if (err == "USERNAME_INVALID") {
} else if (err == qstr("USERNAME_INVALID")) {
_errorText = lang(lng_create_channel_link_invalid);
update();
return true;
} else if (err == "USERNAME_OCCUPIED" && _checkUsername != _channel->username) {
} else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != _channel->username) {
_errorText = lang(lng_create_channel_link_occupied);
update();
return true;
@ -972,7 +975,10 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
_checkRequestId = 0;
QString err(error.type());
if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") {
if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
Ui::hideLayer();
return true;
} else if (err == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
if (_existing) {
Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else {
@ -1213,7 +1219,7 @@ void EditChannelBox::showAll() {
_description.show();
_save.show();
_cancel.show();
if (_channel->amCreator()) {
if (_channel->canEditUsername()) {
_publicLink.show();
} else {
_publicLink.hide();
@ -1264,7 +1270,7 @@ void EditChannelBox::updateMaxHeight() {
if (!_channel->isMegagroup()) {
h += st::newGroupPublicLinkPadding.top() + _sign.height() + st::newGroupPublicLinkPadding.bottom();
}
if (_channel->amCreator()) {
if (_channel->canEditUsername()) {
h += st::newGroupPublicLinkPadding.top() + _publicLink.height() + st::newGroupPublicLinkPadding.bottom();
}
h += st::boxPadding.bottom() + st::newGroupInfoPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom();

View File

@ -4166,7 +4166,7 @@ void HistoryWidget::historyCleared(History *history) {
bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId) {
if (mtpIsFlood(error)) return false;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
PeerData *was = _peer;
Ui::showChatsList();
Ui::showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
@ -4762,7 +4762,7 @@ bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false;
if (_unblockRequest == req) _unblockRequest = 0;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
Ui::showLayer(new InformBox(lang((_peer && _peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
return true;
}

View File

@ -859,7 +859,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
p.setPen(st::black->p);
p.drawText(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop + st::linkFont->ascent, '@' + _peerUser->username);
} else if (_peerChannel && (_peerChannel->isPublic() || _amCreator)) {
} else if (_peerChannel && (_peerChannel->isPublic() || _peerChannel->canEditUsername())) {
addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
}
if (!_peerChannel || !_peerChannel->canViewParticipants() || _peerChannel->isMegagroup()) {
@ -1374,7 +1374,7 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
// profile
top += st::profilePadding.top();
int32 addbyname = 0;
if (_peerChannel && (_amCreator || _peerChannel->isPublic())) {
if (_peerChannel && (_peerChannel->isPublic() || _peerChannel->canEditUsername())) {
_username.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop);
addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
}
@ -1760,7 +1760,7 @@ void ProfileInner::showAll() {
} else {
_deleteChannel.hide();
}
if (_peerChannel->isPublic() || _amCreator) {
if (_peerChannel->isPublic() || _peerChannel->canEditUsername()) {
_username.show();
} else {
_username.hide();

View File

@ -607,6 +607,9 @@ public:
bool isPublic() const {
return flags & MTPDchannel::flag_username;
}
bool canEditUsername() const {
return amCreator() && (flagsFull & MTPDchannelFull::flag_can_set_username);
}
bool amCreator() const {
return flags & MTPDchannel::flag_creator;
}