diff --git a/qml/js/functions.js b/qml/js/functions.js
index 77556b8..166bd1e 100644
--- a/qml/js/functions.js
+++ b/qml/js/functions.js
@@ -47,9 +47,9 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) {
return enhanceMessageText(message.content.text, ignoreEntities);
}
case 'messageSticker':
- return simple ? qsTr("Sticker: %1").arg(message.content.sticker.emoji) : "";
+ return simple ? message.content.sticker.emoji : ""
case 'messageAnimatedEmoji':
- return simple ? qsTr("Animated Emoji: %1").arg(message.content.animated_emoji.sticker.emoji) : "";
+ return simple ? message.content.animated_emoji.sticker.emoji : ""
case 'messagePhoto':
if (message.content.caption.text !== "") {
return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
diff --git a/src/fernschreiberutils.cpp b/src/fernschreiberutils.cpp
index 96ac648..c36aa3e 100644
--- a/src/fernschreiberutils.cpp
+++ b/src/fernschreiberutils.cpp
@@ -37,6 +37,30 @@
#define DEBUG_MODULE FernschreiberUtils
#include "debuglog.h"
+namespace {
+ const QString _TYPE("@type");
+ const QString TEXT("text");
+ const QString EMOJI("emoji");
+ const QString ANIMATED_EMOJI("animated_emoji");
+ const QString STICKER("sticker");
+ const QString USER_ID("user_id");
+
+ const QString MESSAGE_SENDER_TYPE_USER("messageSenderUser");
+
+ const QString MESSAGE_CONTENT_TYPE_TEXT("messageText");
+ const QString MESSAGE_CONTENT_TYPE_STICKER("messageSticker");
+ const QString MESSAGE_CONTENT_TYPE_ANIMATED_EMOJI("messageAnimatedEmoji");
+ const QString MESSAGE_CONTENT_TYPE_PHOTO("messagePhoto");
+ const QString MESSAGE_CONTENT_TYPE_VIDEO("messageVideo");
+ const QString MESSAGE_CONTENT_TYPE_VIDEO_NOTE("messageVideoNote");
+ const QString MESSAGE_CONTENT_TYPE_ANIMATION("messageAnimation");
+ const QString MESSAGE_CONTENT_TYPE_AUDIO("messageAudio");
+ const QString MESSAGE_CONTENT_TYPE_VOICE_NOTE("messageVoiceNote");
+ const QString MESSAGE_CONTENT_TYPE_DOCUMENT("messageDocument");
+ const QString MESSAGE_CONTENT_TYPE_LOCATION("messageLocation");
+ const QString MESSAGE_CONTENT_TYPE_VENUE("messageVenue");
+}
+
FernschreiberUtils::FernschreiberUtils(QObject *parent) : QObject(parent)
{
LOG("Initializing audio recorder...");
@@ -83,44 +107,45 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons
return QString();
}
- const bool myself = !isChannel && (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == currentUserId);
+ const QString contentType(messageContent.value(_TYPE).toString());
+ const QString messageSenderType(messageSender.value(_TYPE).toString());
+ const qlonglong messageSenderUserId = messageSender.value(USER_ID).toLongLong();
+ const bool myself = !isChannel && (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == currentUserId);
- QString contentType = messageContent.value("@type").toString();
-
- if (contentType == "messageText") {
- return messageContent.value("text").toMap().value("text").toString();
+ if (contentType == MESSAGE_CONTENT_TYPE_TEXT) {
+ return messageContent.value(TEXT).toMap().value(TEXT).toString();
}
- if (contentType == "messageSticker") {
- return tr("Sticker: %1").arg(messageContent.value("sticker").toMap().value("emoji").toString());
+ if (contentType == MESSAGE_CONTENT_TYPE_STICKER) {
+ return messageContent.value(STICKER).toMap().value(EMOJI).toString();
}
- if (contentType == "messageAnimatedEmoji") {
- return tr("Animated Emoji: %1").arg(messageContent.value("animated_emoji").toMap().value("sticker").toMap().value("emoji").toString());
+ if (contentType == MESSAGE_CONTENT_TYPE_ANIMATED_EMOJI) {
+ return messageContent.value(ANIMATED_EMOJI).toMap().value(STICKER).toMap().value(EMOJI).toString();
}
- if (contentType == "messagePhoto") {
+ if (contentType == MESSAGE_CONTENT_TYPE_PHOTO) {
return myself ? tr("sent a picture", "myself") : tr("sent a picture");
}
- if (contentType == "messageVideo") {
+ if (contentType == MESSAGE_CONTENT_TYPE_VIDEO) {
return myself ? tr("sent a video", "myself") : tr("sent a video");
}
- if (contentType == "messageVideoNote") {
+ if (contentType == MESSAGE_CONTENT_TYPE_VIDEO_NOTE) {
return myself ? tr("sent a video note", "myself") : tr("sent a video note");
}
- if (contentType == "messageAnimation") {
+ if (contentType == MESSAGE_CONTENT_TYPE_ANIMATION) {
return myself ? tr("sent an animation", "myself") : tr("sent an animation");
}
- if (contentType == "messageAudio") {
+ if (contentType == MESSAGE_CONTENT_TYPE_AUDIO) {
return myself ? tr("sent an audio", "myself") : tr("sent an audio");
}
- if (contentType == "messageVoiceNote") {
+ if (contentType == MESSAGE_CONTENT_TYPE_VOICE_NOTE) {
return myself ? tr("sent a voice note", "myself") : tr("sent a voice note");
}
- if (contentType == "messageDocument") {
+ if (contentType == MESSAGE_CONTENT_TYPE_DOCUMENT) {
return myself ? tr("sent a document", "myself") : tr("sent a document");
}
- if (contentType == "messageLocation") {
+ if (contentType == MESSAGE_CONTENT_TYPE_LOCATION) {
return myself ? tr("sent a location", "myself") : tr("sent a location");
}
- if (contentType == "messageVenue") {
+ if (contentType == MESSAGE_CONTENT_TYPE_VENUE) {
return myself ? tr("sent a venue", "myself") : tr("sent a venue");
}
if (contentType == "messageContactRegistered") {
@@ -130,7 +155,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons
return myself ? tr("joined this chat", "myself") : tr("joined this chat");
}
if (contentType == "messageChatAddMembers") {
- if (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == messageContent.value("member_user_ids").toList().at(0).toLongLong()) {
+ if (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == messageContent.value("member_user_ids").toList().at(0).toLongLong()) {
return myself ? tr("were added to this chat", "myself") : tr("was added to this chat");
} else {
QVariantList memberUserIds = messageContent.value("member_user_ids").toList();
@@ -145,7 +170,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons
}
}
if (contentType == "messageChatDeleteMember") {
- if (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == messageContent.value("user_id").toLongLong()) {
+ if (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == messageContent.value("user_id").toLongLong()) {
return myself ? tr("left this chat", "myself") : tr("left this chat");
} else {
return myself ? tr("have removed %1 from the chat", "myself").arg(getUserName(tdLibWrapper->getUserInformation(messageContent.value("user_id").toString()))) : tr("has removed %1 from the chat").arg(getUserName(tdLibWrapper->getUserInformation(messageContent.value("user_id").toString())));
@@ -176,7 +201,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons
return myself ? tr("upgraded this group to a supergroup", "myself") : tr("upgraded this group to a supergroup");
}
if (contentType == "messageCustomServiceAction") {
- return messageContent.value("text").toString();
+ return messageContent.value(TEXT).toString();
}
if (contentType == "messagePinMessage") {
return myself ? tr("changed the pinned message", "myself") : tr("changed the pinned message");
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index 1b40f18..83c6ec1 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -730,10 +730,6 @@
hat diesen Chat verlassen
-
-
- Sticker: %1
-
myself
@@ -934,10 +930,6 @@
hat eine Videonachricht geschickt
-
-
- Animiertes Emoji: %1
-
ImagePage
@@ -1893,10 +1885,6 @@
Bild: %1
-
-
- Sticker: %1
-
Audio: %1
@@ -2290,9 +2278,5 @@
hat ein Spiel gesendet
-
-
- Animiertes Emoji: %1
-
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index 8124049..a59539a 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -732,10 +732,6 @@ messages
left this chat
-
-
- Sticker: %1
-
myself
@@ -936,10 +932,6 @@ messages
sent a video note
-
-
- Animated Emoji: %1
-
ImagePage
@@ -1895,10 +1887,6 @@ messages
Picture: %1
-
-
- Sticker: %1
-
Audio: %1
@@ -2292,9 +2280,5 @@ messages
sent a game
-
-
- Animated Emoji: %1
-
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index 4f10ac7..149dd05 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -730,10 +730,6 @@
dejó esta conversación
-
-
- Pegatina: %1
-
myself
@@ -934,10 +930,6 @@
envió una nota de video
-
-
- Emoji animado: %1
-
ImagePage
@@ -1893,10 +1885,6 @@
Imagen: %1
-
-
- Pegatina: %1
-
Audio: %1
@@ -2290,9 +2278,5 @@
envió un juego
-
-
- Emoji animado: %1
-
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index c85025b..88d303e 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -646,10 +646,6 @@
FernschreiberUtils
-
-
- Tarra: %1
-
myself
@@ -935,10 +931,6 @@
lähetti videoviestin
-
-
-
-
ImagePage
@@ -1894,10 +1886,6 @@
Kuva: %1
-
-
- Tarra: %1
-
Äänite: %1
@@ -2291,9 +2279,5 @@
lähetti pelin
-
-
-
-
diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts
index b955826..93e6422 100644
--- a/translations/harbour-fernschreiber-fr.ts
+++ b/translations/harbour-fernschreiber-fr.ts
@@ -730,10 +730,6 @@
a quitté cette conversation
-
-
- Autocollant : %1
-
myself
@@ -934,10 +930,6 @@
a envoyé une note vidéo
-
-
-
-
ImagePage
@@ -1893,10 +1885,6 @@
Image : %1
-
-
- Autocollant : %1
-
Audio : %1
@@ -2290,9 +2278,5 @@
a envoyé un jeu
-
-
-
-
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index 070c24e..0e245f1 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -718,10 +718,6 @@
kilépett a csevegésből
-
-
- Matrica: %1
-
myself
@@ -920,10 +916,6 @@
-
-
-
-
ImagePage
@@ -1866,10 +1858,6 @@
Kép: %1
-
-
- Matrica: %1
-
Audió: %1
@@ -2262,9 +2250,5 @@
-
-
-
-
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index fc51c52..1a936fe 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -730,10 +730,6 @@
ha lasciato questa chat
-
-
- Sticker: %1
-
myself
@@ -934,10 +930,6 @@
ha inviato un videomessaggio
-
-
-
-
ImagePage
@@ -1893,10 +1885,6 @@
Foto: %1
-
-
- Sticker: %1
-
Audio: %1
@@ -2290,9 +2278,5 @@
ha inviato un gioco
-
-
-
-
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index 87c912e..5df100e 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -742,10 +742,6 @@
opuścił ten czat
-
-
- Naklejka: %1
-
myself
@@ -948,10 +944,6 @@
wysłał notatkę video
-
-
- Animowane Emoji: %1
-
ImagePage
@@ -1920,10 +1912,6 @@
Obraz: %1
-
-
- Naklejka: %1
-
Dźwięk: %1
@@ -2318,9 +2306,5 @@
wysłał grę
-
-
- Animowane Emoji: %1
-
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index ac28f62..dc560ae 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -745,10 +745,6 @@
покунул(а) чат
-
-
- Стикер: %1
-
myself
@@ -951,10 +947,6 @@
отправил(а) видео заметку
-
-
-
-
ImagePage
@@ -1923,10 +1915,6 @@
Картинка: %1
-
-
- Стикер: %1
-
Аудио: %1
@@ -2321,9 +2309,5 @@
отправил(а) игру
-
-
-
-
diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts
index fcc0028..db41dc3 100644
--- a/translations/harbour-fernschreiber-sk.ts
+++ b/translations/harbour-fernschreiber-sk.ts
@@ -742,10 +742,6 @@
opustil tento čet
-
-
- Nálepka: %1
-
myself
@@ -948,10 +944,6 @@
poslal video-poznámku
-
-
-
-
ImagePage
@@ -1920,10 +1912,6 @@
Obrázok: %1
-
-
- Nálepka: %1
-
Zvuk: %1
@@ -2318,9 +2306,5 @@
poslal hru
-
-
-
-
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index 0954d93..2442809 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -730,10 +730,6 @@
lämnade denna chatt
-
-
- Dekal: %1
-
myself
@@ -934,10 +930,6 @@
skickade ett videomeddelande
-
-
- Animerad emoji: %1
-
ImagePage
@@ -1893,10 +1885,6 @@
Bild: %1
-
-
- Dekal: %1
-
Ljud: %1
@@ -2290,9 +2278,5 @@
skickade ett spel
-
-
- Animerad emoji: %1
-
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index c0e12bf..f9e2c78 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -719,10 +719,6 @@
离开此对话
-
-
- 表情贴图: %1
-
myself
@@ -921,10 +917,6 @@
发送视频消息
-
-
-
-
ImagePage
@@ -1867,10 +1859,6 @@
图片: %1
-
-
- 表情贴图: %1
-
音频: %1
@@ -2263,9 +2251,5 @@
发送游戏
-
-
-
-
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index 4b5e325..77fb04c 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -730,10 +730,6 @@
left this chat
-
-
- Sticker: %1
-
myself
@@ -934,10 +930,6 @@
sent a video note
-
-
-
-
ImagePage
@@ -1893,10 +1885,6 @@
Picture: %1
-
-
- Sticker: %1
-
Audio: %1
@@ -2290,9 +2278,5 @@
-
-
-
-