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; _checkRequestId = 0;
QString err(error.type()); 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) { if (_existing) {
Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else { } else {
@ -953,11 +956,11 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
onPrivacyChange(); onPrivacyChange();
} }
return true; return true;
} else if (err == "USERNAME_INVALID") { } else if (err == qstr("USERNAME_INVALID")) {
_errorText = lang(lng_create_channel_link_invalid); _errorText = lang(lng_create_channel_link_invalid);
update(); update();
return true; 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); _errorText = lang(lng_create_channel_link_occupied);
update(); update();
return true; return true;
@ -972,7 +975,10 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
_checkRequestId = 0; _checkRequestId = 0;
QString err(error.type()); 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) { if (_existing) {
Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else { } else {
@ -1213,7 +1219,7 @@ void EditChannelBox::showAll() {
_description.show(); _description.show();
_save.show(); _save.show();
_cancel.show(); _cancel.show();
if (_channel->amCreator()) { if (_channel->canEditUsername()) {
_publicLink.show(); _publicLink.show();
} else { } else {
_publicLink.hide(); _publicLink.hide();
@ -1264,7 +1270,7 @@ void EditChannelBox::updateMaxHeight() {
if (!_channel->isMegagroup()) { if (!_channel->isMegagroup()) {
h += st::newGroupPublicLinkPadding.top() + _sign.height() + st::newGroupPublicLinkPadding.bottom(); 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::newGroupPublicLinkPadding.top() + _publicLink.height() + st::newGroupPublicLinkPadding.bottom();
} }
h += st::boxPadding.bottom() + st::newGroupInfoPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.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) { bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId) {
if (mtpIsFlood(error)) return false; 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; PeerData *was = _peer;
Ui::showChatsList(); Ui::showChatsList();
Ui::showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); 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 (mtpIsFlood(error)) return false;
if (_unblockRequest == req) _unblockRequest = 0; 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))); Ui::showLayer(new InformBox(lang((_peer && _peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
return true; return true;
} }

View File

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

View File

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