no report spam if history is empty or there are out messages

This commit is contained in:
John Preston 2016-03-14 08:54:24 +03:00
parent 2a9f24d774
commit cab19a141f
1 changed files with 22 additions and 2 deletions

View File

@ -3796,6 +3796,13 @@ void HistoryWidget::updateReportSpamStatus() {
if (!_peer || (_peer->isUser() && (peerToUser(_peer->id) == MTP::authedId() || isNotificationsUser(_peer->id) || isServiceUser(_peer->id) || _peer->asUser()->botInfo))) { if (!_peer || (_peer->isUser() && (peerToUser(_peer->id) == MTP::authedId() || isNotificationsUser(_peer->id) || isServiceUser(_peer->id) || _peer->asUser()->botInfo))) {
_reportSpamStatus = dbiprsHidden; _reportSpamStatus = dbiprsHidden;
return; return;
} else if (!_firstLoadRequest && _history->isEmpty()) {
_reportSpamStatus = dbiprsNoButton;
if (cReportSpamStatuses().contains(_peer->id)) {
cRefReportSpamStatuses().remove(_peer->id);
Local::writeReportSpamStatuses();
}
return;
} else { } else {
ReportSpamStatuses::const_iterator i = cReportSpamStatuses().constFind(_peer->id); ReportSpamStatuses::const_iterator i = cReportSpamStatuses().constFind(_peer->id);
if (i != cReportSpamStatuses().cend()) { if (i != cReportSpamStatuses().cend()) {
@ -3833,7 +3840,7 @@ void HistoryWidget::updateReportSpamStatus() {
} }
} }
} }
if (!cContactsReceived()) { if (!cContactsReceived() || _firstLoadRequest) {
_reportSpamStatus = dbiprsUnknown; _reportSpamStatus = dbiprsUnknown;
} else if (_peer->isUser() && _peer->asUser()->contact > 0) { } else if (_peer->isUser() && _peer->asUser()->contact > 0) {
_reportSpamStatus = dbiprsHidden; _reportSpamStatus = dbiprsHidden;
@ -3851,8 +3858,21 @@ void HistoryWidget::updateReportSpamStatus() {
void HistoryWidget::requestReportSpamSetting() { void HistoryWidget::requestReportSpamSetting() {
if (_reportSpamSettingRequestId >= 0 || !_peer) return; if (_reportSpamSettingRequestId >= 0 || !_peer) return;
bool outFound = false;
for (auto i : _history->blocks) {
for (auto j : i->items) {
if (j->out()) {
outFound = true;
break;
}
}
}
if (outFound) {
_reportSpamStatus = dbiprsNoButton;
} else {
_reportSpamSettingRequestId = MTP::send(MTPmessages_GetPeerSettings(_peer->input), rpcDone(&HistoryWidget::reportSpamSettingDone), rpcFail(&HistoryWidget::reportSpamSettingFail)); _reportSpamSettingRequestId = MTP::send(MTPmessages_GetPeerSettings(_peer->input), rpcDone(&HistoryWidget::reportSpamSettingDone), rpcFail(&HistoryWidget::reportSpamSettingFail));
} }
}
void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req) { void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req) {
if (req != _reportSpamSettingRequestId) return; if (req != _reportSpamSettingRequestId) return;