From 1e9d2f024776fde5ce10ed642f593269e80b0cb1 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 15 Apr 2019 16:33:57 +0300 Subject: [PATCH] Fix pushMessageContent captions. GitOrigin-RevId: cb52936eaaa0208349d442c49e833eb833c0c96f --- td/generate/scheme/td_api.tl | 16 ++++++++-------- td/generate/scheme/td_api.tlo | Bin 151012 -> 150916 bytes td/telegram/NotificationManager.cpp | 26 ++++++++++++++++++++++++++ td/telegram/NotificationType.cpp | 8 ++++---- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2d05c3ce..649a079b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 9b32c2a29cfaed1b9e8abb6adbff15671c9bb3d1..f76139beb6f4e0deb8a7847f653df42a69ed8bdd 100644 GIT binary patch delta 833 zcmaDdo3mv$=LQ#PmMu$6_igr&X1NMs1$^K!1GAiS1k57zu$b#3(+F;-?=gU-tPCT@i0Ko2 z7+IzV7&59roKazj&)Y|UvT#Q-P8Mv|hUhXdLNc=k8XQ0|+^#S&hUv(Gvz8b$8o*6w eo?d9os6NS)bvmaBqc_;d_6QTk?GYwSJ(2)C<}vvI delta 839 zcmZpf&G}?D=LQ#Pmghgzzi;-CX1NMs1$^K!1GAcnpfgjnv$6hQhW25kPq|Z zg%`~cWy{L#`L-BjOq}{HJUJ2+|gt#u|&6G z?HvYhNlf2)=9T4VCZ{qm;4=1(7R*>4ZN?CYRVmsqA5PF_oBN#hNFkUG+mhC2D*$T5QA3e!VG#)h8&nWdPtsUnJn0*KH1=x04OeEAR52uG3p?N z&cZAD;Gh#h4+%?=)b{BU^ciK~ikYX|u4L4nzDJu;1u3+73>YnNx_o+!0W5uS7%@gn zH}GL(nf}3mQ3c`_2}3--o}L1fgj0r maxrE!fSb-dUC@|OeUc~Z^p(bp-e9HeKa3f-|1f6ikpuvyl35V| diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 06a0e9f2..e6b8d21b 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -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 #include @@ -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) { diff --git a/td/telegram/NotificationType.cpp b/td/telegram/NotificationType.cpp index 7875bd89..d23dbb3f 100644 --- a/td/telegram/NotificationType.cpp +++ b/td/telegram/NotificationType.cpp @@ -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( - 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( - 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( - 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( - 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: