Verified Commit e579f8fc authored by Mari's avatar Mari Committed by aguestuser

[215] use per-membership language for recycling notifications

parent a6fba7f7
......@@ -410,6 +410,9 @@ const notifications = {
channelDestructionFailed: phoneNumber =>
`Der Kanal mit der Signal-Nummer: ${phoneNumber} konnte nicht zerstört werden`,
channelEnqueuedForRecycling:
'Hallo! Dieser Kanal wird wegen mangelnder Nutzung deaktiviert. Um zu verhindern, dass es deaktiviert wird, senden Sie innerhalb der nächsten 24 Stunden "INFO". Weitere Informationen finden Sie unter signalboost.info/how-to.',
channelRecycled:
'Der Kanal wurde wegen Inaktivität deaktiviert. Gehe auf https://signalboost.info um einen neuen Kanal zu erstellen.',
......
......@@ -402,7 +402,7 @@ const notifications = {
`Failed to destroy channel for phone number: ${phoneNumber}`,
channelEnqueuedForRecycling:
'Hello! This channel is about to be deactivated due to lack of use. To continue using the channel, use any command within the next 24 hours. For more info, visit signalboost.info/how-to.',
'Hello! This channel is about to be deactivated due to lack of use. To prevent it from being deactivated, send "INFO" within the next 24 hours. For more info, visit signalboost.info/how-to.',
channelRecycled:
'Channel deactivated due to lack of use. To create a new channel, visit https://signalboost.info',
......
......@@ -410,6 +410,9 @@ const notifications = {
channelDestroyed: 'El canal ha sido destruido permanentemente por sus admins.',
channelEnqueuedForRecycling:
'¡Hola! Este canal está a punto de desactivarse por falta de uso. Para evitar que se desactive, envíe "INFO" en las próximas 24 horas. Para obtener más información, visite signalboost.info/how-to. ',
channelDestructionFailed: phoneNumber =>
`Error al destruir el canal para el número de teléfono: ${phoneNumber}`,
......
......@@ -415,6 +415,9 @@ const notifications = {
channelDestroyed:
'La chaîne et tous les enregistrements associés ont été définitivement détruits.',
channelEnqueuedForRecycling:
"Bonjour! Cette chaîne est sur le point d'être désactivée faute d'utilisation. Pour éviter qu'il ne soit désactivé, envoyez 'INFO' dans les prochaines 24 heures.Pour plus d'informations, visitez signalboost.info/how-to. ",
channelDestructionFailed: phoneNumber =>
`Impossible de détruire la chaîne pour le numéro de téléphone: ${phoneNumber}`,
......
const signal = require('../../signal')
const signal = require('../../signal/signal')
const { isEmpty } = require('lodash')
const { statuses } = require('../../util')
const { messagesIn } = require('../../dispatcher/strings/messages')
......@@ -31,7 +31,6 @@ const enqueueRecycleablePhoneNumber = async ({ phoneNumbers }) => {
message: `Successfully enqueued ${phoneNumber} for recycling.`,
}
} catch (e) {
console.log(e)
return {
status: statuses.ERROR,
message: `There was an error trying to enqueue ${phoneNumber} for recycling.`,
......@@ -42,11 +41,17 @@ const enqueueRecycleablePhoneNumber = async ({ phoneNumbers }) => {
}
const notifyAdmins = async channel => {
await signal.broadcastMessage(
channelRepository.getAdminPhoneNumbers(channel),
signal.sdMessageOf(
channel,
messagesIn(channel.language).notifications.channelEnqueuedForRecycling,
const recipients = await channelRepository.getAdminMemberships(channel)
return Promise.all(
recipients.map(recipient =>
signal.sendMessage(
recipient.memberPhoneNumber,
signal.sdMessageOf(
channel,
messagesIn(recipient.language).notifications.channelEnqueuedForRecycling,
),
),
),
)
}
......
......@@ -26,12 +26,17 @@ const recycle = async channelPhoneNumber => {
/********************
* HELPER FUNCTIONS
********************/
// TODO @mari - convert these functions to use sendMessage in language per membership
// (Channel) -> Channel
// (Channel) -> Promise([])
const notifyMembers = async channel => {
await signal.broadcastMessage(
channelRepository.getMemberPhoneNumbers(channel),
signal.sdMessageOf(channel, messagesIn(channel.language).notifications.channelRecycled),
const recipients = await channelRepository.getMemberPhoneNumbers(channel)
return Promise.all(
recipients.map(recipient =>
signal.sendMessage(
recipient.memberPhoneNumber,
signal.sdMessageOf(channel, messagesIn(recipient.language).notifications.channelRecycled),
),
),
)
}
......
import { expect } from 'chai'
import { afterEach, beforeEach, describe, it } from 'mocha'
import sinon from 'sinon'
import signal from '../../../../app/signal'
import signal from '../../../../app/signal/signal'
import channelRepository from '../../../../app/db/repositories/channel'
import { genPhoneNumber } from '../../../support/factories/phoneNumber'
import recycleablePhoneNumberRepository from '../../../../app/db/repositories/recycleablePhoneNumber'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment