2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

merged with master spam report buttons, 40 layer not compiling!

This commit is contained in:
John Preston
2015-09-11 13:29:21 +03:00
42 changed files with 1244 additions and 213 deletions

View File

@@ -781,7 +781,12 @@ void MainWidget::deleteHistoryPart(PeerData *peer, const MTPmessages_AffectedHis
updPtsUpdated(d.vpts.v, d.vpts_count.v);
int32 offset = d.voffset.v;
if (!MTP::authedId() || offset <= 0) return;
if (!MTP::authedId()) return;
if (offset <= 0) {
cRefReportSpamStatuses().remove(peer->id);
Local::writeReportSpamStatuses();
return;
}
MTP::send(MTPmessages_DeleteHistory(peer->input, d.voffset), rpcDone(&MainWidget::deleteHistoryPart, peer));
}
@@ -842,6 +847,8 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
text = lang(lng_failed_add_not_mutual);
} else if (error.type() == "USER_ALREADY_PARTICIPANT" && user->botInfo) {
text = lang(lng_bot_already_in_group);
} else if (error.type() == "PEER_FLOOD") {
text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)));
}
App::wnd()->showLayer(new ConfirmBox(text, true));
return false;
@@ -912,7 +919,7 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu
}
}
bool MainWidget::sendPhotoFailed(uint64 randomId, const RPCError &error) {
bool MainWidget::sendPhotoFail(uint64 randomId, const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (error.type() == qsl("PHOTO_INVALID_DIMENSIONS")) {
@@ -926,6 +933,16 @@ bool MainWidget::sendPhotoFailed(uint64 randomId, const RPCError &error) {
_resendImgRandomIds.push_back(randomId);
return true;
}
return sendMessageFail(error);
}
bool MainWidget::sendMessageFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (error.type() == qsl("PEER_FLOOD")) {
App::wnd()->showLayer(new ConfirmBox(lng_cant_send_to_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))), true));
return true;
}
return false;
}
@@ -1103,8 +1120,8 @@ void MainWidget::sendPreparedText(History *hist, const QString &text, MsgId repl
flags |= MTPDmessage::flag_from_id;
}
MTPVector<MTPMessageEntity> localEntities = linksToMTP(textParseLinks(sendingText, itemTextParseOptions(hist, App::self()).flags));
hist->addToBack(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(hist->peer->id), MTPint(), MTPint(), MTP_int(replyTo), MTP_int(unixtime()), msgText, media, MTPnullMarkup, localEntities));
hist->sendRequestId = MTP::send(MTPmessages_SendMessage(MTP_int(sendFlags), hist->peer->input, MTP_int(replyTo), msgText, MTP_long(randomId), MTPnullMarkup, localEntities), App::main()->rpcDone(&MainWidget::sentUpdatesReceived, randomId), RPCFailHandlerPtr(), 0, 0, hist->sendRequestId);
hist->addToBack(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(fromChannelName ? 0 : MTP::authedId()), peerToMTP(hist->peer->id), MTPPeer(), MTPint(), MTP_int(replyTo), MTP_int(unixtime()), msgText, media, MTPnullMarkup, localEntities, MTPint()));
hist->sendRequestId = MTP::send(MTPmessages_SendMessage(MTP_int(sendFlags), hist->peer->input, MTP_int(replyTo), msgText, MTP_long(randomId), MTPnullMarkup, localEntities), rpcDone(&MainWidget::sentUpdatesReceived, randomId), rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
finishForwarding(hist);
@@ -1891,7 +1908,7 @@ void MainWidget::serviceNotification(const QString &msg, const MTPMessageMedia &
HistoryItem *item = 0;
while (textSplit(sendingText, leftText, MaxMessageSize)) {
MTPVector<MTPMessageEntity> localEntities = linksToMTP(textParseLinks(sendingText, _historyTextOptions.flags));
item = App::histories().addToBack(MTP_message(MTP_int(flags), MTP_int(clientMsgId()), MTP_int(ServiceUserId), MTP_peerUser(MTP_int(MTP::authedId())), MTPint(), MTPint(), MTPint(), MTP_int(unixtime()), MTP_string(sendingText), media, MTPnullMarkup, localEntities), unread ? 1 : 2);
item = App::histories().addToBack(MTP_message(MTP_int(flags), MTP_int(clientMsgId()), MTP_int(ServiceUserId), MTP_peerUser(MTP_int(MTP::authedId())), MTPPeer(), MTPint(), MTPint(), MTP_int(unixtime()), MTP_string(sendingText), media, MTPnullMarkup, localEntities, MTPint()), unread ? 1 : 2);
}
if (item) {
history.peerMessagesUpdated(item->history()->peer->id);
@@ -2067,6 +2084,10 @@ void MainWidget::clearBotStartToken(PeerData *peer) {
}
}
void MainWidget::contactsReceived() {
history.contactsReceived();
}
void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) {
if (!back && (!peerId || (_stack.size() == 1 && _stack[0]->type() == HistoryStackItem && _stack[0]->peer->id == peerId))) {
back = true;
@@ -3481,7 +3502,7 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
case mtpc_updateShortMessage: {
const MTPDupdateShortMessage &d(updates.c_updateShortMessage());
if (!App::userLoaded(d.vuser_id.v) || (d.has_fwd_from_id() && !App::userLoaded(d.vfwd_from_id.v))) {
if (!App::userLoaded(d.vuser_id.v) || (d.has_fwd_from_id() && !App::peerLoaded(peerFromMTP(d.vfwd_from_id)))) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
return getDifference();
}
@@ -3490,7 +3511,7 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
return;
}
bool out = (d.vflags.v & MTPDmessage_flag_out);
HistoryItem *item = App::histories().addToBack(MTP_message(d.vflags, d.vid, out ? MTP_int(MTP::authedId()) : d.vuser_id, MTP_peerUser(out ? d.vuser_id : MTP_int(MTP::authedId())), d.vfwd_from_id, d.vfwd_date, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities));
HistoryItem *item = App::histories().addToBack(MTP_message(d.vflags, d.vid, out ? MTP_int(MTP::authedId()) : d.vuser_id, MTP_peerUser(out ? d.vuser_id : MTP_int(MTP::authedId())), d.vfwd_from_id, d.vfwd_date, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint()));
if (item) {
history.peerMessagesUpdated(item->history()->peer->id);
}
@@ -3501,7 +3522,7 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
case mtpc_updateShortChatMessage: {
const MTPDupdateShortChatMessage &d(updates.c_updateShortChatMessage());
bool noFrom = !App::userLoaded(d.vfrom_id.v);
if (!App::chatLoaded(d.vchat_id.v) || noFrom || (d.has_fwd_from_id() && !App::userLoaded(d.vfwd_from_id.v))) {
if (!App::chatLoaded(d.vchat_id.v) || noFrom || (d.has_fwd_from_id() && !App::peerLoaded(peerFromMTP(d.vfwd_from_id)))) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
if (noFrom) App::api()->requestFullPeer(App::chatLoaded(d.vchat_id.v));
return getDifference();
@@ -3510,7 +3531,7 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
_byPtsUpdates.insert(ptsKey(SkippedUpdates), updates);
return;
}
HistoryItem *item = App::histories().addToBack(MTP_message(d.vflags, d.vid, d.vfrom_id, MTP_peerChat(d.vchat_id), d.vfwd_from_id, d.vfwd_date, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities));
HistoryItem *item = App::histories().addToBack(MTP_message(d.vflags, d.vid, d.vfrom_id, MTP_peerChat(d.vchat_id), d.vfwd_from_id, d.vfwd_date, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint()));
if (item) {
history.peerMessagesUpdated(item->history()->peer->id);
}
@@ -3526,7 +3547,6 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
App::histSentDataByItem(randomId, peerId, text);
feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date
if (peerId) {
HistoryItem *item = App::histItemById(peerToChannel(peerId), d.vid.v);
if (!text.isEmpty()) {
@@ -3534,7 +3554,7 @@ void MainWidget::handleUpdates(const MTPUpdates &updates, uint64 randomId) {
if (item && ((hasLinks && !item->hasTextLinks()) || (!hasLinks && item->textHasLinks()))) {
bool was = item->hasTextLinks();
item->setText(text, d.has_entities() ? linksFromMTP(d.ventities.c_vector().v) : LinksInText());
item->initDimensions(0);
item->initDimensions();
itemResized(item);
if (!was && item->hasTextLinks()) {
item->history()->addToOverview(item, OverviewLinks);
@@ -3661,6 +3681,10 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateWebPage: {
const MTPDupdateWebPage &d(update.c_updateWebPage());
if (!updPtsUpdated(d.vpts.v, d.vpts_count.v)) {
_byPtsUpdate.insert(ptsKey(SkippedUpdate), update);
return;
}
App::feedWebPage(d.vwebpage);
history.updatePreview();
webPagesUpdate();