2528 - Rocket notifications hotfix
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-10-21 13:25:52 +02:00
parent 86d3e2d689
commit c87783b446
5 changed files with 40 additions and 15 deletions

View File

@ -3,7 +3,7 @@ module.exports = Self => {
description: 'Sends a RocketChat message to a working worker or department channel',
accessType: 'WRITE',
accepts: [{
arg: 'workerId',
arg: 'recipientId',
type: 'Number',
required: true,
description: 'The worker id of the destinatary'
@ -23,21 +23,23 @@ module.exports = Self => {
}
});
Self.sendCheckingPresence = async(ctx, workerId, message) => {
if (!workerId) return false;
Self.sendCheckingPresence = async(ctx, recipientId, message) => {
if (!recipientId) return false;
const models = Self.app.models;
const account = await models.Account.findById(workerId);
const account = await models.Account.findById(recipientId);
const userId = ctx.req.accessToken.userId;
if (recipientId == userId) return false;
if (!account)
throw new Error(`Could not send message "${message}" to worker id ${workerId} from user ${userId}`);
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
const query = `SELECT worker_isWorking(?) isWorking`;
const [result] = await Self.rawSql(query, [workerId]);
const [result] = await Self.rawSql(query, [recipientId]);
if (!result.isWorking) {
const workerDepartment = await models.WorkerDepartment.findById(workerId, {
const workerDepartment = await models.WorkerDepartment.findById(recipientId, {
include: {
relation: 'department'
}
@ -46,7 +48,7 @@ module.exports = Self => {
const channelName = department && department.chatName;
if (channelName)
return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`);
return Self.send(ctx, `#${channelName}`, `@${account.name} ${message}`);
}
return Self.send(ctx, `@${account.name}`, message);

View File

@ -72,5 +72,13 @@
"Deleted absence": "The worker <strong>{{author}}</strong> has deleted an absence of type '{{absenceType}}' to <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> for day {{dated}}.",
"I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})",
"I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})",
"Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
"Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"agencyModeFk": "Agency",
"clientFk": "Client",
"zoneFk": "Zone",
"warehouseFk": "Warehouse",
"shipped": "Shipped",
"landed": "Landed",
"addressFk": "Address",
"companyFk": "Company"
}

View File

@ -140,7 +140,6 @@
"Role already assigned": "Role already assigned",
"Invalid role name": "Invalid role name",
"Role name must be written in camelCase": "Role name must be written in camelCase",
"can't be set": "can't be set",
"Email already exists": "Email already exists",
"User already exists": "User already exists",
"Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral",
@ -149,5 +148,13 @@
"I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
"I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})",
"You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación",
"Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
"Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"agencyModeFk": "Agencia",
"clientFk": "Cliente",
"zoneFk": "Zona",
"warehouseFk": "Almacén",
"shipped": "F. envío",
"landed": "F. entrega",
"addressFk": "Consignatario",
"companyFk": "Empresa"
}

View File

@ -140,6 +140,7 @@ module.exports = Self => {
let changesMade = '';
for (let change in changedProperties) {
let value = changedProperties[change];
let oldValue = originalTicket[change];
if (value instanceof Date) {
value = new Intl.DateTimeFormat('es', {
year: '2-digit',
@ -149,9 +150,10 @@ module.exports = Self => {
minute: '2-digit',
second: '2-digit'
}).format(value);
oldValue = value;
}
changesMade += `${change}: ${value}\r\n`;
changesMade += `\r\n~${$t(change)}: ${value}~ ➔ *${$t(change)}: ${oldValue}*`;
}
const message = $t('Changed this data from the ticket', {

View File

@ -45,8 +45,8 @@ describe('ticket componentUpdate()', () => {
req: {
accessToken: {userId: 101},
headers: {origin: 'http://localhost'},
__: (value, params) => {
return params.nickname;
__: value => {
return value;
}
}
};
@ -79,7 +79,13 @@ describe('ticket componentUpdate()', () => {
let ctx = {
args: {clientFk: 102,
agencyModeFk: 7},
req: {accessToken: {userId: 101}}};
req: {
accessToken: {userId: 101},
headers: {origin: 'http://localhost'},
__: value => {
return value;
}
}};
await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId,
zoneId, warehouseId, companyId, shipped, landed, isDeleted, option);