Fix pushMessageContent captions.

GitOrigin-RevId: cb52936eaaa0208349d442c49e833eb833c0c96f
This commit is contained in:
levlam 2019-04-15 16:33:57 +03:00
parent 79cc50ed41
commit 1e9d2f0247
4 changed files with 38 additions and 12 deletions

View File

@ -1943,8 +1943,8 @@ pushMessageContentHidden is_pinned:Bool = PushMessageContent;
//@description An animation message (GIF-style) @animation Message content; may be null @caption Animation caption @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentAnimation animation:animation caption:string is_pinned:Bool = PushMessageContent;
//@description An audio message @audio Message content; may be null @caption Audio caption @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentAudio audio:audio caption:string is_pinned:Bool = PushMessageContent;
//@description An audio message @audio Message content; may be null @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentAudio audio:audio is_pinned:Bool = PushMessageContent;
//@description A message with a user contact @name Contact's name @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentContact name:string is_pinned:Bool = PushMessageContent;
@ -1952,8 +1952,8 @@ pushMessageContentContact name:string is_pinned:Bool = PushMessageContent;
//@description A contact has registered with Telegram
pushMessageContentContactRegistered = PushMessageContent;
//@description A document message (a general file) @document Message content; may be null @caption Document caption @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentDocument document:document caption:string is_pinned:Bool = PushMessageContent;
//@description A document message (a general file) @document Message content; may be null @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentDocument document:document is_pinned:Bool = PushMessageContent;
//@description A message with a game @title Game title @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentGame title:string is_pinned:Bool = PushMessageContent;
@ -1961,8 +1961,8 @@ pushMessageContentGame title:string is_pinned:Bool = PushMessageContent;
//@description A new high score was achieved in a game @title Game title, empty for pinned message @score New score, 0 for pinned message @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentGameScore title:string score:int32 is_pinned:Bool = PushMessageContent;
//@description A message with an invoice from a bot @title Product title @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentInvoice title:string is_pinned:Bool = PushMessageContent;
//@description A message with an invoice from a bot @price Product price @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentInvoice price:string is_pinned:Bool = PushMessageContent;
//@description A message with a location @is_live True, if the location is live @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentLocation is_live:Bool is_pinned:Bool = PushMessageContent;
@ -1988,8 +1988,8 @@ pushMessageContentVideo video:video caption:string is_secret:Bool is_pinned:Bool
//@description A video note message @video_note Message content; may be null @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentVideoNote video_note:videoNote is_pinned:Bool = PushMessageContent;
//@description A voice note message @voice_note Message content; may be null @caption Voice note caption @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentVoiceNote voice_note:voiceNote caption:string is_pinned:Bool = PushMessageContent;
//@description A voice note message @voice_note Message content; may be null @is_pinned True, if the message is a pinned message with the specified content
pushMessageContentVoiceNote voice_note:voiceNote is_pinned:Bool = PushMessageContent;
//@description A newly created basic group
pushMessageContentBasicGroupChatCreate = PushMessageContent;

Binary file not shown.

View File

@ -50,6 +50,7 @@
#include "td/utils/Slice.h"
#include "td/utils/Time.h"
#include "td/utils/tl_parsers.h"
#include "td/utils/utf8.h"
#include <algorithm>
#include <iterator>
@ -3292,6 +3293,31 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
}
}
}
if (!arg.empty()) {
uint32 emoji = [&] {
if (ends_with(loc_key, "PHOTO")) {
return 0x1F5BC;
}
if (ends_with(loc_key, "ANIMATION")) {
return 0x1F3AC;
}
if (ends_with(loc_key, "DOCUMENT")) {
return 0x1F4CE;
}
if (ends_with(loc_key, "VIDEO")) {
return 0x1F4F9;
}
return 0;
}();
if (emoji != 0) {
string prefix;
append_utf8_character(prefix, emoji);
prefix += ' ';
if (begins_with(arg, prefix)) {
arg = arg.substr(prefix.size());
}
}
}
if (has_json_object_field(custom, "edit_date")) {
if (random_id != 0) {

View File

@ -179,7 +179,7 @@ class NotificationTypePushMessage : public NotificationType {
if (key == "MESSAGE_AUDIO") {
auto audios_manager = G()->td().get_actor_unsafe()->audios_manager_.get();
return td_api::make_object<td_api::pushMessageContentAudio>(
audios_manager->get_audio_object(document.file_id), arg, is_pinned);
audios_manager->get_audio_object(document.file_id), is_pinned);
}
break;
case 'B':
@ -226,7 +226,7 @@ class NotificationTypePushMessage : public NotificationType {
if (key == "MESSAGE_DOCUMENT") {
auto documents_manager = G()->td().get_actor_unsafe()->documents_manager_.get();
return td_api::make_object<td_api::pushMessageContentDocument>(
documents_manager->get_document_object(document.file_id), arg, is_pinned);
documents_manager->get_document_object(document.file_id), is_pinned);
}
break;
case 'F':
@ -288,7 +288,7 @@ class NotificationTypePushMessage : public NotificationType {
if (key == "MESSAGE_STICKER") {
auto stickers_manager = G()->td().get_actor_unsafe()->stickers_manager_.get();
return td_api::make_object<td_api::pushMessageContentSticker>(
stickers_manager->get_sticker_object(document.file_id), arg, is_pinned);
stickers_manager->get_sticker_object(document.file_id), trim(arg), is_pinned);
}
break;
case 'T':
@ -313,7 +313,7 @@ class NotificationTypePushMessage : public NotificationType {
if (key == "MESSAGE_VOICE_NOTE") {
auto voice_notes_manager = G()->td().get_actor_unsafe()->voice_notes_manager_.get();
return td_api::make_object<td_api::pushMessageContentVoiceNote>(
voice_notes_manager->get_voice_note_object(document.file_id), arg, is_pinned);
voice_notes_manager->get_voice_note_object(document.file_id), is_pinned);
}
break;
default: