Skip to content

Commit

Permalink
Disallow sending direct messages to invalid contacts
Browse files Browse the repository at this point in the history
Strings taken from the Android app.
  • Loading branch information
threema-danilo committed Apr 2, 2020
1 parent cb4a4be commit c0e64c4
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion public/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@
"MESSAGE_NOT_SUPPORTED": "«{receiverName}» nemůže tuto zprávu přijmout.",
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» nemůže tuto hlasovou zprávu přijmout.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» nemůže přijmout soubory.",
"CONTACT_BLOCKED": "Nelze odesílat zprávy blokovanému kontaktu.",
"CONTACT_BLOCKED": "Nelze odesílat zprávy blokovanému kontaktu.",
"CONTACT_INVALID": "Nelze odeslat zprávu neplatnému kontaktu.",
"ERROR_OCCURRED": "Došlo k chybě.",
"FILE_TOO_LARGE": "Soubory větší než {maxmb} MiB nelze odeslat",
"FILE_TOO_LARGE_WEB": "Aktuálně nelze prostřednictvím Threema Web odeslat soubory větší než 15 MiB",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» kann noch keine Sprachnachrichten erhalten.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» kann noch keine Dateien erhalten.",
"CONTACT_BLOCKED": "Sie können keine Nachrichten an blockierte Kontakte senden.",
"CONTACT_INVALID": "Sie können keine Nachrichten an einen ungültigen Kontakt senden.",
"ERROR_OCCURRED": "Es ist ein Fehler aufgetreten.",
"FILE_TOO_LARGE": "Dateien grösser als {maxmb} MiB können nicht versendet werden",
"FILE_TOO_LARGE_WEB": "Aktuell können keine Dateien grösser als 15 MiB über Threema Web versendet werden",
Expand Down
3 changes: 2 additions & 1 deletion public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@
"MESSAGE_NOT_SUPPORTED": "«{receiverName}» cannot receive this message.",
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» cannot receive voice messages.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» cannot receive files.",
"CONTACT_BLOCKED": "You cannot send messages to a blocked contact.",
"CONTACT_BLOCKED": "You cannot send messages to a blocked contact.",
"CONTACT_INVALID": "You cannot send messages to an invalid contact.",
"ERROR_OCCURRED": "An error occurred.",
"FILE_TOO_LARGE": "Files larger than {maxmb} MiB cannot be sent",
"FILE_TOO_LARGE_WEB": "Currently files larger than 15 MiB cannot be sent through Threema Web",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» no puede recibir mensajes de voz.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» no puede recibir ficheros.",
"CONTACT_BLOCKED": "No puede enviar mensajes a un contacto bloqueado.",
"CONTACT_INVALID": "No puede enviar mensajes a un contacto no válido.",
"ERROR_OCCURRED": "Ha ocurrido un error.",
"FILE_TOO_LARGE": "No se pueden enviar archivos de más de {maxmb} MiB",
"FILE_TOO_LARGE_WEB": "Actualmente no se pueden enviar archivos de más de 15 MiB a través de Threema Web",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "« {receiverName} » ne peut pas recevoir des messages audio.",
"FILE_MESSAGES_NOT_SUPPORTED": "« {receiverName} » ne peut pas recevoir de fichiers.",
"CONTACT_BLOCKED": "Vous ne pouvez pas envoyer des messages à un contact bloqué.",
"CONTACT_INVALID": "Vous ne pouvez pas envoyer de message à un contact erroné.",
"ERROR_OCCURRED": "Une erreur est apparue.",
"FILE_TOO_LARGE": "Les fichiers plus grands que {maxmb} MiB ne peuvent pas être envoyés",
"FILE_TOO_LARGE_WEB": "Actuellement les fichiers plus grands que 15 MiB ne peuvent pas être envoyés avec Threema Web",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» kan geen spraakberichten ontvangen.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» kan geen bestanden ontvangen.",
"CONTACT_BLOCKED": "Je kan geen berichten sturen aan een geblokkeerde contactpersoon.",
"CONTACT_INVALID": "U kunt geen berichten versturen aan ongeldige contactpersonen.",
"ERROR_OCCURRED": "Een fout is opgetreden.",
"FILE_TOO_LARGE": "Bestanden groter dan {maxmb} MiB kunnen niet worden verstuurd",
"FILE_TOO_LARGE_WEB": "Momenteel kunnen bestanden groter dan 15 MiB niet worden verstuurd met Threema Web",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» nie może otrzymywać wiadomości głosowych.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» nie może otrzymywać plików.",
"CONTACT_BLOCKED": "Nie możesz wysyłać wiadomości do zablokowanego kontaktu.",
"CONTACT_INVALID": "Nie możesz wysyłać wiadomości do nieprawidłowego kontaktu.",
"ERROR_OCCURRED": "Wystąpił błąd.",
"FILE_TOO_LARGE": "Pliki większe niż {maxmb} MiB nie mogą być wysłyane",
"FILE_TOO_LARGE_WEB": "Obecnie pliki większe niż 15 MiB nie mogą być wysyłane przez Threema Web",
Expand Down
1 change: 1 addition & 0 deletions public/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
"AUDIO_MESSAGES_NOT_SUPPORTED": "«{receiverName}» não pode receber mensagens de voz.",
"FILE_MESSAGES_NOT_SUPPORTED": "«{receiverName}» não pode receber arquivos.",
"CONTACT_BLOCKED": "Você não pode enviar mensagens para um contato bloqueado.",
"CONTACT_INVALID": "Você não pode enviar mensagens a um contato inválido.",
"ERROR_OCCURRED": "Um erro ocorreu.",
"FILE_TOO_LARGE": "Arquivos maiores que {maxmb} MiB não podem ser enviados",
"FILE_TOO_LARGE_WEB": "Actualmente, arquivos maiores que 15 MiB não podem ser enviados através do site da Threema Web.",
Expand Down
13 changes: 10 additions & 3 deletions src/services/webclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1759,9 +1759,16 @@ export class WebClientService {
// Try to load receiver
const receiver = this.receivers.getData(baseReceiver);

// Check blocked flag
if (isContactReceiver(receiver) && receiver.isBlocked) {
throw this.$translate.instant('error.CONTACT_BLOCKED');
if (isContactReceiver(receiver)) {
// Check blocked flag
if (receiver.isBlocked) {
throw this.$translate.instant('error.CONTACT_BLOCKED');
}

// Check identity state
if (receiver.state === 'INVALID') {
throw this.$translate.instant('error.CONTACT_INVALID');
}
}

// Decide on subtype
Expand Down

0 comments on commit c0e64c4

Please sign in to comment.