Commit a01ec126 authored by gagz's avatar gagz

Fixing french translation conflict

parents 7c26eef2 54640dfa
......@@ -55,7 +55,7 @@ const execute = async (executable, dispatchable) => {
const maybeAddAdmin = async (db, channel, sender, phoneNumberInput) => {
const cr = messagesIn(sender.language).commandResponses.add
if (!(sender.type === ADMIN)) {
return Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.unauthorized })
return Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.notAdmin })
}
const { isValid, phoneNumber } = validator.parseValidPhoneNumber(phoneNumberInput)
if (!isValid) return { status: statuses.ERROR, message: cr.invalidNumber(phoneNumberInput) }
......@@ -86,10 +86,7 @@ const showHelp = async (db, channel, sender) => {
const showInfo = async (db, channel, sender) => {
const cr = messagesIn(sender.language).commandResponses.info
return {
status: statuses.SUCCESS,
message: sender.type === ADMIN ? cr.admin(channel) : cr.subscriber(channel),
}
return { status: statuses.SUCCESS, message: cr[sender.type](channel) }
}
// JOIN
......@@ -112,7 +109,7 @@ const addSubscriber = (db, channel, sender, language, cr) =>
const maybeRemoveSender = async (db, channel, sender) => {
const cr = messagesIn(sender.language).commandResponses.leave
return sender.type === NONE
? Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.unauthorized })
? Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.notSubscriber })
: removeSender(db, channel, sender, cr)
}
......@@ -131,7 +128,7 @@ const maybeRemoveAdmin = async (db, channel, sender, adminNumber) => {
const { isValid, phoneNumber: validNumber } = validator.parseValidPhoneNumber(adminNumber)
if (!(sender.type === ADMIN)) {
return { status: statuses.UNAUTHORIZED, message: cr.unauthorized }
return { status: statuses.UNAUTHORIZED, message: cr.notAdmin }
}
if (!isValid) {
return { status: statuses.ERROR, message: cr.invalidNumber(adminNumber) }
......@@ -154,7 +151,7 @@ const maybeRenameChannel = async (db, channel, sender, newName) => {
const cr = messagesIn(sender.language).commandResponses.rename
return sender.type === ADMIN
? renameChannel(db, channel, newName, cr)
: Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.unauthorized })
: Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.notAdmin })
}
const renameChannel = (db, channel, newName, cr) =>
......@@ -169,7 +166,7 @@ const renameChannel = (db, channel, newName, cr) =>
const maybeToggleResponses = async (db, channel, sender, responsesEnabled) => {
const cr = messagesIn(sender.language).commandResponses.toggleResponses
if (!(sender.type === ADMIN)) {
return Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.unauthorized })
return Promise.resolve({ status: statuses.UNAUTHORIZED, message: cr.notAdmin })
}
return toggleResponses(db, channel, responsesEnabled, sender, cr)
}
......
......@@ -18,13 +18,13 @@ const {
const messageTypes = {
BROADCAST_MESSAGE: 'BROADCAST_MESSAGE',
BROADCAST_RESPONSE: 'BROADCAST_RESPONSE',
HOTLINE_MESSAGE: 'HOTLINE_MESSAGE',
COMMAND_RESULT: 'COMMAND_RESULT',
NEW_ADMIN_WELCOME: 'NEW_ADMIN_WELCOME',
SIGNUP_MESSAGE: 'SIGNUP_MESSAGE',
}
const { BROADCAST_MESSAGE, BROADCAST_RESPONSE, COMMAND_RESULT, SIGNUP_MESSAGE } = messageTypes
const { BROADCAST_MESSAGE, HOTLINE_MESSAGE, COMMAND_RESULT, SIGNUP_MESSAGE } = messageTypes
const { ADMIN } = memberTypes
......@@ -38,8 +38,8 @@ const dispatch = async ({ commandResult, dispatchable }) => {
switch (messageType) {
case BROADCAST_MESSAGE:
return broadcast(dispatchable)
case BROADCAST_RESPONSE:
return handleBroadcastResponse(dispatchable)
case HOTLINE_MESSAGE:
return handleHotlineMessage(dispatchable)
case COMMAND_RESULT:
return handleCommandResult({ commandResult, dispatchable })
case SIGNUP_MESSAGE:
......@@ -54,7 +54,7 @@ const parseMessageType = (commandResult, { sender, channel }) => {
if (commandResult.status === statuses.NOOP) {
if (sender.type === ADMIN) return BROADCAST_MESSAGE
if (channel.phoneNumber === signupPhoneNumber) return SIGNUP_MESSAGE
return BROADCAST_RESPONSE
return HOTLINE_MESSAGE
}
return COMMAND_RESULT
}
......@@ -69,7 +69,7 @@ const handleSignupMessage = async ({ sock, channel, sender, sdMessage }) => {
notification: notifications.signupRequestReceived(sender.phoneNumber, sdMessage.messageBody),
recipients: channelRepository.getAdminPhoneNumbers(channel),
})
// respond to signpu requester
// respond to signup requester
return notify({
sock,
channel,
......@@ -78,20 +78,17 @@ const handleSignupMessage = async ({ sock, channel, sender, sdMessage }) => {
})
}
const handleBroadcastResponse = dispatchable => {
const handleHotlineMessage = dispatchable => {
const {
channel: { responsesEnabled },
sender: { language },
sender: { language, type },
} = dispatchable
if (!responsesEnabled) {
return respond({
...dispatchable,
message: messagesIn(language).notifications.unauthorized,
status: statuses.UNAUTHORIZED,
})
}
return relayBroadcastResponse(dispatchable)
const disabledMessage = messagesIn(language).notifications.hotlineMessagesDisabled(
type === memberTypes.SUBSCRIBER,
)
return responsesEnabled
? relayHotlineMessage(dispatchable)
: respond({ ...dispatchable, status: statuses.UNAUTHORIZED, message: disabledMessage })
}
const handleCommandResult = async ({ commandResult, dispatchable }) => {
......@@ -136,16 +133,16 @@ const handleNotifications = async ({ commandResult, dispatchable }) => {
const broadcast = async ({ db, sock, channel, sdMessage }) => {
const recipients = channel.memberships.map(m => m.memberPhoneNumber)
return signal
.broadcastMessage(sock, recipients, format({ channel, sdMessage }))
.broadcastMessage(sock, recipients, addHeader({ channel, sdMessage }))
.then(() => countBroacast({ db, channel }))
}
// Dispatchable -> Promise<void>
const relayBroadcastResponse = async ({ db, sock, channel, sender, sdMessage }) => {
const relayHotlineMessage = async ({ db, sock, channel, sender, sdMessage }) => {
const { language } = sender
const recipients = channelRepository.getAdminPhoneNumbers(channel)
const notification = messagesIn(language).notifications.broadcastResponseSent(channel)
const outMessage = format({ channel, sdMessage, messageType: BROADCAST_RESPONSE, language })
const notification = messagesIn(language).notifications.hotlineMessageSent(channel)
const outMessage = addHeader({ channel, sdMessage, messageType: HOTLINE_MESSAGE, language })
return signal
.broadcastMessage(sock, recipients, outMessage)
.then(() => countBroacast({ db, channel }))
......@@ -153,46 +150,28 @@ const relayBroadcastResponse = async ({ db, sock, channel, sender, sdMessage })
}
// (DbusInterface, string, Sender, string?, string?) -> Promise<void>
const respond = ({ db, sock, channel, message, sender, command }) => {
const outMessage = format({
channel,
sdMessage: sdMessageOf(channel, message),
command,
language: sender.language,
})
const respond = ({ db, sock, channel, message, sender }) => {
return signal
.sendMessage(sock, sender.phoneNumber, outMessage)
.sendMessage(sock, sender.phoneNumber, sdMessageOf(channel, message))
.then(() => countCommand({ db, channel }))
}
const notify = ({ sock, channel, notification, recipients }) => {
const sdMessage = format({ channel, sdMessage: sdMessageOf(channel, notification) })
return signal.broadcastMessage(sock, recipients, sdMessage)
}
const notify = ({ sock, channel, notification, recipients }) =>
signal.broadcastMessage(sock, recipients, sdMessageOf(channel, notification))
/**********
* HELPERS
**********/
// { Channel, string, string, string, string } -> string
const format = ({ channel, sdMessage, messageType, command, language }) => {
const prefix = resolvePrefix(channel, messageType, command, language)
const addHeader = ({ channel, sdMessage, messageType, language }) => {
const prefix =
messageType === HOTLINE_MESSAGE
? `[${messagesIn(language).prefixes.hotlineMessage}]\n`
: `[${channel.name}]\n`
return { ...sdMessage, messageBody: `${prefix}${sdMessage.messageBody}` }
}
// Channel, string, string, string -> string
const resolvePrefix = (channel, messageType, command, language) => {
const prefixes = messagesIn(language).prefixes
if (command === commands.RENAME || command === commands.INFO || command === commands.HELP) {
// RENAME messages must provide their own header (b/c channel name changed since last query)
// INFO & HELP messages provide their own prefixes
return ''
}
if (messageType === BROADCAST_RESPONSE) {
// subscriber responses get a special header so they don't look like broadcast messages from admins
// we clone message to preserve attachments
return `[${prefixes.broadcastResponse}]\n`
}
// base formatting for broadcast messages; we clone sdMessage to preserve attachements
return `[${channel.name}]\n`
}
const countBroacast = ({ db, channel }) =>
// TODO(@zig): add prometheus counter increment here
messageCountRepository.incrementBroadcastCount(
......@@ -210,7 +189,7 @@ module.exports = {
/**********/
broadcast,
dispatch,
format,
addHeader,
parseMessageType,
respond,
notify,
......
const { upperCase } = require('lodash')
const { memberTypes } = require('../../../../db/repositories/membership')
const {
getAdminMemberships,
getSubscriberMemberships,
} = require('../../../../db/repositories/channel')
const systemName = 'the signalboost system administrator'
const unauthorized = 'Whoops! You are not authorized to do that on this channel.'
const notAdmin =
'Sorry, only admins are allowed to issue that command. Send HELP for a list of valid commands.'
const notSubscriber =
'Your command could not be processed because you are not subscribed to this channel. Send HELLO to subscribe.'
const invalidNumber = phoneNumber =>
`Whoops! "${phoneNumber}" is not a valid phone number. Phone numbers must include country codes prefixed by a '+'.`
`"${phoneNumber}" is not a valid phone number. Phone numbers must include country codes prefixed by a '+'.`
const support = `----------------------------
HOW IT WORKS
......@@ -35,11 +39,6 @@ Learn more: https://signalboost.info`
const notifications = {
adminAdded: (commandIssuer, addedAdmin) => `New Admin ${addedAdmin} added by ${commandIssuer}`,
broadcastResponseSent: channel =>
`Your message was forwarded to the admins of [${channel.name}].
Send HELP to see commands I understand! :)`,
deauthorization: adminPhoneNumber => `
${adminPhoneNumber} has been removed from this channel because their safety number changed.
......@@ -52,8 +51,18 @@ Check with ${adminPhoneNumber} to make sure they still control their phone, then
ADD ${adminPhoneNumber}
Until then, they will be unable to send messages to or read messages from this channel.`,
noop: "Whoops! That's not a command!",
unauthorized: "Whoops! I don't understand that.\n Send HELP to see commands I understand!",
hotlineMessageSent: channel =>
`Your message was anonymously forwarded to the admins of [${
channel.name
}]. Include your phone number if you want admins to respond to you individually.
Send HELP to list valid commands.`,
hotlineMessagesDisabled: isSubscriber =>
isSubscriber
? 'Sorry, incoming messages are not enabled on this channel. Send HELP to list valid commands.'
: 'Sorry, incoming messages are not enabled on this channel. Send HELP to list valid commands or HELLO to subscribe.',
welcome: (addingAdmin, channelPhoneNumber) => `
You were just made an admin of this Signalboost channel by ${addingAdmin}. Welcome!
......@@ -74,21 +83,12 @@ const commandResponses = {
add: {
success: num => `${num} added as an admin.`,
unauthorized,
// unauthorized: notSubscriber,
notAdmin,
dbError: num => `Whoops! There was an error adding ${num} as an admin. Please try again!`,
invalidNumber,
},
// REMOVE
remove: {
success: num => `${num} removed as an admin.`,
unauthorized,
dbError: num => `Whoops! There was an error trying to remove ${num}. Please try again!`,
invalidNumber,
targetNotAdmin: num => `Whoops! ${num} is not an admin. Can't remove them.`,
},
// HELP
help: {
......@@ -146,10 +146,12 @@ ESPAÑOL / FRANÇAIS
// INFO
info: {
admin: channel => `---------------------------
[memberTypes.ADMIN]: channel => `---------------------------
CHANNEL INFO:
---------------------------
You are an admin of this channel.
name: ${channel.name}
phone number: ${channel.phoneNumber}
admins: ${getAdminMemberships(channel).length}
......@@ -159,27 +161,30 @@ messages sent: ${channel.messageCount.broadcastIn}
${support}`,
subscriber: channel => `---------------------------
[memberTypes.SUBSCRIBER]: channel => `---------------------------
CHANNEL INFO:
---------------------------
You are subscribed to this channel.
name: ${channel.name}
phone number: ${channel.phoneNumber}
responses: ${channel.responsesEnabled ? 'ON' : 'OFF'}
subscribers: ${getSubscriberMemberships(channel).length}
${support}`,
unauthorized,
},
// RENAME
[memberTypes.NONE]: channel => `---------------------------
CHANNEL INFO:
---------------------------
rename: {
success: (oldName, newName) =>
`[${newName}]\nChannel renamed from "${oldName}" to "${newName}".`,
dbError: (oldName, newName) =>
`[${oldName}]\nWhoops! There was an error renaming the channel [${oldName}] to [${newName}]. Try again!`,
unauthorized,
You are not subscribed to this channel. Send HELLO to subscribe.
name: ${channel.name}
phone number: ${channel.phoneNumber}
subscribers: ${getSubscriberMemberships(channel).length}
${support}`,
},
// JOIN
......@@ -198,14 +203,34 @@ Reply with HELP to learn more or GOODBYE to unsubscribe.`,
leave: {
success: `You've been removed from the channel! Bye!`,
error: `Whoops! There was an error removing you from the channel. Please try again!`,
unauthorized,
notSubscriber,
},
// REMOVE
remove: {
success: num => `${num} removed as an admin.`,
notAdmin,
dbError: num => `Whoops! There was an error trying to remove ${num}. Please try again!`,
invalidNumber,
targetNotAdmin: num => `Whoops! ${num} is not an admin. Can't remove them.`,
},
// RENAME
rename: {
success: (oldName, newName) =>
`[${newName}]\nChannel renamed from "${oldName}" to "${newName}".`,
dbError: (oldName, newName) =>
`[${oldName}]\nWhoops! There was an error renaming the channel [${oldName}] to [${newName}]. Try again!`,
notAdmin,
},
// RESPONSES_ON / RESPONSES_OFF
toggleResponses: {
success: setting => `Subscriber responses turned ${upperCase(setting)}.`,
unauthorized,
notAdmin,
dbError: setting =>
`Whoops! There was an error trying to set responses to ${setting}. Please try again!`,
},
......@@ -226,14 +251,15 @@ Send HELP to list commands I understand.`,
error: phoneNumber =>
`Failed to update safety number for ${phoneNumber}. Try again or contact a maintainer!`,
invalidNumber,
unauthorized,
notAdmin,
dbError: phoneNumber =>
`Whoops! There was an error updating the safety number for ${phoneNumber}. Please try again!`,
},
}
const prefixes = {
broadcastResponse: `SUBSCRIBER RESPONSE`,
// TODO(aguestuser|2019-12-21): change this to HOTLINE MESSAGE
hotlineMessage: `SUBSCRIBER RESPONSE`,
}
module.exports = {
......
const { upperCase } = require('lodash')
const { memberTypes } = require('../../../../db/repositories/membership')
const {
getAdminMemberships,
getSubscriberMemberships,
} = require('../../../../db/repositories/channel')
const systemName = 'El administrador del sistema de Signalboost'
const unauthorized = '¡Lo siento! Usted no está autorizado para hacerlo en este canal.'
const notAdmin =
'Lo sentimos, solo los admins pueden emitir ese comando. Envíe AYUDA para obtener una lista de comandos válidos.'
const notSubscriber =
'No se pudo procesar su comando porque no está suscrito a este canal. Envía HOLA para suscribirse.'
const invalidNumber = phoneNumber =>
`¡Lo siento! "${phoneNumber}" no es un número de teléfono válido. Los números de teléfono deben incluir códigos del país con el prefijo '+'.`
......@@ -37,9 +41,18 @@ const notifications = {
adminAdded: (commandIssuer, addedAdmin) =>
`Nuevo administrador ${addedAdmin} agregado por ${commandIssuer}`,
broadcastResponseSent: channel =>
`Su mensaje fue enviado a los administradores de [${channel.name}].
¡Envíe AYUDA para ver los comandos que entiendo! :)`,
hotlineMessageSent: channel =>
`Su mensaje se envió de forma anónima a los admins de [${
channel.name
}]. Incluya su número de teléfono si desea que los administradores le respondan individualmente.
Enviar AYUDA para enumerar comandos válidos.
`,
hotlineMessagesDisabled: isSubscriber =>
isSubscriber
? 'Lo siento, los mensajes entrantes no están habilitados en este canal. Enviar AYUDA para enumerar comandos válidos.'
: 'Los siento, los mensajes entrantes no están habilitados en este canal. Envíe AYUDA para enumerar comandos válidos o HOLA para suscribirse.',
deauthorization: adminPhoneNumber => `
${adminPhoneNumber} se ha eliminado de este canal porque su número de seguridad cambió.
......@@ -81,7 +94,7 @@ const commandResponses = {
add: {
success: num => `${num} agregó como administrador.`,
unauthorized,
notAdmin,
dbError: num =>
`¡Lo siento! Se produjo un error al agregar a ${num} como administrador. ¡Inténtelo de nuevo!`,
invalidNumber: num =>
......@@ -92,7 +105,7 @@ const commandResponses = {
remove: {
success: num => `${num} eliminado como administrador.`,
unauthorized,
notAdmin,
dbError: num =>
`¡Lo siento! Se produjo un error al intentar eliminar a ${num}. ¡Inténtelo de nuevo!`,
invalidNumber: num =>
......@@ -157,10 +170,12 @@ ENGLISH / FRANÇAIS
// INFO
info: {
admin: channel => `------------------------------
[memberTypes.ADMIN]: channel => `------------------------------
INFO DEL CANAL
------------------------------
Usted es admin de este canal.
nombre: ${channel.name}
número de teléfono: ${channel.phoneNumber}
admins: ${getAdminMemberships(channel).length}
......@@ -169,16 +184,29 @@ respuestas: ${channel.responsesEnabled ? 'ACTIVADAS' : 'DESACTIVADAS'}
mensajes enviados: ${channel.messageCount.broadcastIn}
${support}`,
subscriber: channel => `------------------------------
[memberTypes.SUBSCRIBER]: channel => `------------------------------
INFO DEL CANAL
------------------------------
Usted es suscriptor de este canal.
nombre: ${channel.name}
número de teléfono: ${channel.phoneNumber}
respuestas: ${channel.responsesEnabled ? 'ACTIVADAS' : 'DESACTIVADAS'}
suscriptorxs: ${getSubscriberMemberships(channel).length}
${support}`,
[memberTypes.NONE]: channel => `------------------------------
INFO DEL CANAL
------------------------------
Usted no es suscriptor de este canal. Envía HOLA para suscribirse.
nombre: ${channel.name}
número de teléfono: ${channel.phoneNumber}
respuestas: ${channel.responsesEnabled ? 'ACTIVADAS' : 'DESACTIVADAS'}
suscriptorxs: ${getSubscriberMemberships(channel).length}
${support}`,
unauthorized,
},
// RENAME
......@@ -187,7 +215,7 @@ ${support}`,
success: (oldName, newName) => `[${newName}]\nCanal renombrado de "${oldName}" a "${newName}".`,
dbError: (oldName, newName) =>
`[${oldName}]\n¡Lo siento! Se produjo un error al cambiar el nombre del canal [${oldName}] a [${newName}]. ¡Inténtelo de nuevo!`,
unauthorized,
notAdmin,
},
// JOIN
......@@ -206,14 +234,14 @@ Responda con AYUDA para obtener más información o ADIÓS para darse de baja.`,
leave: {
success: `¡Usted ha sido eliminado del canal! ¡Adiós!`,
error: `¡Lo siento! Se produjo un error al eliminarlo del canal. ¡Inténtelo de nuevo!`,
unauthorized,
notSubscriber,
},
// RESPONSES_ON / RESPONSES_OFF
toggleResponses: {
success: setting => `Respuestas del suscriptor configurado en ${upperCase(setting)}.`,
unauthorized,
notAdmin,
dbError: setting =>
`¡Lo siento! Se produjo un error al intentar establecer respuestas a ${setting}. ¡Inténtelo de nuevo!`,
},
......@@ -234,14 +262,14 @@ Envíe AYUDA para ver los comandos que comprendo.`,
error: phoneNumber =>
`Error al actualizar el número de seguridad para ${phoneNumber}. ¡Inténtelo de nuevo o contacta a un mantenedor!`,
invalidNumber,
unauthorized,
notAdmin,
dbError: phoneNumber =>
`¡Lo siento! Se produjo un error al actualizar el número de seguridad de ${phoneNumber}. ¡Inténtelo de nuevo!`,
},
}
const prefixes = {
broadcastResponse: `RESPUESTA DEL SUSCRIPTOR`,
hotlineMessage: `RESPUESTA DEL SUSCRIPTOR`,
}
module.exports = {
......
const { upperCase } = require('lodash')
const { memberTypes } = require('../../../../db/repositories/membership')
const {
getAdminMemberships,
getSubscriberMemberships,
} = require('../../../../db/repositories/channel')
const systemName = 'l\'administrateurice du système Signalboost'
const unauthorized = 'Oups! Vous n’êtes pas autorisé·e à faire cela sur ce canal.'
const systemName = 'le maintenant du système Signalboost'
const notAdmin =
'Déso, seul·e·s les admins sont autorisé·es à exécuter cette commande. Envoyez AIDE pour une liste de commandes valides.'
const notSubscriber =
"Votre commande n'a pas pu être traitée car vous n'êtes pas abonné·e à ce canal. Envoyez ALLO pour vous abonner."
const invalidNumber = phoneNumber =>
`Oups! "${phoneNumber}" n’est pas un numéro de téléphone valide. Les numéros de téléphone doivent comprendre le code pays précédé par un «+».`
......@@ -36,10 +42,17 @@ const notifications = {
adminAdded: (commandIssuer, addedAdmin) =>
`Nouvel·le admin ${addedAdmin} ajouté·e par ${commandIssuer}`,
broadcastResponseSent: channel =>
`Votre message a été communiqué aux admins de [${channel.name}].
hotlineMessageSent: channel =>
`Votre message a été transmis de manière anonyme aux admins de [${
channel.name
}]. Indiquez votre numéro de téléphone si vous souhaitez que les administrateuricess vous répondent individuellement.'
Envoyez AIDE pour voir la liste des commandes que je comprends.`,
Envoyez AIDE pour voir la liste des commandes que je comprends! :)`,
hotlineMessagesDisabled: isSubscriber =>
isSubscriber
? 'Déso, les messages entrants ne sont pas activés sur ce canal. Envoyez AIDE pour répertorier les commandes valides.'
: 'Déso, les messages entrants ne sont pas activés sur ce canal. Envoyez AIDE pour lister les commandes valides ou ALLO pour vous abonner.',
deauthorization: adminPhoneNumber => `
${adminPhoneNumber} a été retiré·e de ce canal parce que leur numéro de sécurité a changé.
......@@ -77,7 +90,7 @@ const commandResponses = {
add: {
success: num => `${num} ajouté·e comme admin.`,
unauthorized,
notAdmin,
dbError: num =>
`Oups! Une erreur s’est produite en tentant de supprimer ${num}. Veuillez essayer de nouveau.`,
invalidNumber,
......@@ -87,7 +100,7 @@ const commandResponses = {
remove: {
success: num => `${num} supprimé·e des admins.`,
unauthorized,
notAdmin,
dbError: num =>
`Oups! Une erreur s'est produite lors de la tentative de suppression ${num}. Veuillez essayer de nouveau.`,
invalidNumber,
......@@ -151,10 +164,12 @@ ESPAÑOL / ENGLISH
// INFO
info: {
admin: channel => `---------------------------
[memberTypes.ADMIN]: channel => `---------------------------
INFOS CANAL
---------------------------
Vous êtes admin de ce canal.
nom: ${channel.name}
numéro de téléphone: ${channel.phoneNumber}
admins: ${getAdminMemberships(channel).length}
......@@ -164,17 +179,30 @@ messages envoyés: ${channel.messageCount.broadcastIn}
${support}`,
subscriber: channel => `---------------------------
[memberTypes.SUBSCRIBER]: channel => `---------------------------
INFOS CANAL
---------------------------
Vous êtes abonné·e à ce canal.
nom: ${channel.name}
numéro de téléphone: ${channel.phoneNumber}
réponses: ${channel.responsesEnabled ? 'ON' : 'OFF'}
abonné·e·s: ${getSubscriberMemberships(channel).length}
${support}`,
unauthorized,
[memberTypes.NONE]: channel => `---------------------------
INFOS CANAL
---------------------------
Vous n'êtes pas abonné à cette chaîne. Envoyez AIDE pour vous abonner.
nom: ${channel.name}
numéro de téléphone: ${channel.phoneNumber}
abonnées: ${getSubscriberMemberships(channel).length}
${support}`,
},
// RENAME
......@@ -183,7 +211,7 @@ ${support}`,
success: (oldName, newName) => `[${newName}]\nNom du canal changé de "${oldName}" à "${newName}”.`,
dbError: (oldName, newName) =>
`[${oldName}]\nOups! Une erreur s’est produite en tentant de renommer le canal de [${oldName}] à [${newName}]. Veuillez essayer de nouveau!`,
unauthorized,
notAdmin,
},
// JOIN
......@@ -202,14 +230,14 @@ Répondez avec AIDE pour en savoir plus ou ADIEU pour vous désinscrire.`,
leave: {
success: `Vous êtes maintenant désabonné·e de ce canal. Au revoir!`,
error: `Oups! Une erreur s’est produite en tentant de vous désabonner de ce canal. Veuillez essayer de nouveau!`,
unauthorized,
notSubscriber,
},
// RESPONSES_ON / RESPONSES_OFF
toggleResponses: {
success: setting => `Réponses des abonnées passées à ${upperCase(setting)}.`,
unauthorized,
notAdmin,
dbError: setting =>
`Oups! Une erreur s’est produite en tentant de changer les réponses à ${setting}. Veuillez essayer de nouveau!`,
},
......@@ -230,14 +258,14 @@ Commande AIDE pour la liste des commandes que je comprends.`,
error: phoneNumber =>
`La mise à jour du numéro de sécurité de ${phoneNumber} a échoué. Veuillez essayer à nouveau ou contacter un·e mainteneur·euse!`,
invalidNumber,
unauthorized,
notAdmin,
dbError: phoneNumber =>
`Oups! Une erreur s’est produite lors de la mise à jour du numéro de sécurité de ${phoneNumber}. Veuillez essayer à nouveau!`,
},
}
const prefixes = {
broadcastResponse: `RÉPONSES ABONNÉ·E·S`,
hotlineMessage: `RÉPONSES ABONNÉ·E·S`,
}
module.exports = {
......
......@@ -141,7 +141,7 @@ describe('executing commands', () => {
expect(result).to.eql({
command: commands.ADD,
status: statuses.UNAUTHORIZED,
message: CR.add.unauthorized,
message: CR.add.notAdmin,
})
})
})
......@@ -197,7 +197,7 @@ describe('executing commands', () => {
expect(await processCommand(dispatchable)).to.eql({
command: commands.INFO,
status: statuses.SUCCESS,
message: CR.info.admin(channel),
message: CR.info[memberTypes.ADMIN](channel),
})
})
})
......@@ -209,7 +209,7 @@ describe('executing commands', () => {
expect(await processCommand(dispatchable)).to.eql({
command: commands.INFO,
status: statuses.SUCCESS,
message: CR.info.subscriber(channel),
message: CR.info[memberTypes.SUBSCRIBER](channel),
})
})
})
......@@ -221,7 +221,7 @@ describe('executing commands', () => {
expect(await processCommand(dispatchable)).to.eql({
command: commands.INFO,