diff --git a/packages/rocketchat-api/server/v1/misc.js b/packages/rocketchat-api/server/v1/misc.js index 54724769dffa..adab119233b5 100644 --- a/packages/rocketchat-api/server/v1/misc.js +++ b/packages/rocketchat-api/server/v1/misc.js @@ -191,7 +191,7 @@ RocketChat.API.v1.addRoute('invite.email', { authRequired: true }, { return RocketChat.API.v1.failure('Invalid email address'); } - const result = Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationEmail', [this.bodyParams.email], this.bodyParams.language)); + const result = Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationEmail', [this.bodyParams.email], this.bodyParams.language, this.bodyParams.realname)); if (result.indexOf(this.bodyParams.email) >= 0) { return RocketChat.API.v1.success(); } else { @@ -210,7 +210,7 @@ RocketChat.API.v1.addRoute('invite.sms', { authRequired: true }, { return RocketChat.API.v1.failure('Invalid number'); } - const result = Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationSMS', [phone], this.bodyParams.language)); + const result = Meteor.runAsUser(this.userId, () => Meteor.call('sendInvitationSMS', [phone], this.bodyParams.language, this.bodyParams.realname)); if (result.indexOf(phone) >= 0) { return RocketChat.API.v1.success(); } else { diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 076aa5d5bfda..086de041305c 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1540,11 +1540,11 @@ "invisible": "invisible", "Invisible": "Invisible", "Invitation": "Invitation", - "Invitation_Email_Default":"Hi, a friend (username=[Username]) has invited you to chat on [Site_Name]. Click [Invite_Link] to respond.", + "Invitation_Email_Default":"Hi, your friend [Username] has invited you to chat on [Site_Name]. Click [Invite_Link] to respond.", "Invitation_Email_Description": "You may use the following placeholders:
", "Invitation_Subject": "Invitation Subject", "Invitation_Subject_Default": "Invitation to chat from your friend [Username] on [Site_Name]", - "Invitation_SMS_Default_Body": "Hi, a friend (username=[Username]) has invited you to chat on Viasat Connect. Click [Invite_Link] to respond.", + "Invitation_SMS_Default_Body": "Hi, your friend [name] has invited you to chat on Viasat Connect. Click [Invite_Link] to respond.", "Invite_user_to_join_channel": "Invite one user to join this channel", "Invite_user_to_join_channel_all_from": "Invite all users from [#channel] to join this channel", "Invite_user_to_join_channel_all_to": "Invite all users from this channel to join [#channel]", diff --git a/packages/rocketchat-i18n/i18n/es.i18n.json b/packages/rocketchat-i18n/i18n/es.i18n.json index 77132ea6a7f1..f9434233f79a 100644 --- a/packages/rocketchat-i18n/i18n/es.i18n.json +++ b/packages/rocketchat-i18n/i18n/es.i18n.json @@ -1428,11 +1428,11 @@ "invisible": "invisible", "Invisible": "Invisible", "Invitation": "Invitación", - "Invitation_Email_Default":"Hola, un amigo (username = [Username]) lo ha invitado a chatear en [Site_Name]. Haga clic en [Invite_Link] para responder.", + "Invitation_Email_Default":"Hola, su amigo [Username] lo ha invitado a chatear en [Site_Name]. Haga clic en [Invite_Link] para responder.", "Invitation_Email_Description": "Es posible utilizar los siguientes marcadores:
", "Invitation_Subject": "Invitation Subject", "Invitation_Subject_Default": "Invitación al chat de su amigo [Username] en [Site_Name]", - "Invitation_SMS_Default_Body": "Hola, un amigo (username = [Username]) lo ha invitado a chatear en [Site_Name]. Haga clic en [Invite_Link] para responder.", + "Invitation_SMS_Default_Body": "Hola, su amigo [name] lo ha invitado a chatear en [Site_Name]. Haga clic en [Invite_Link] para responder.", "Invite_user_to_join_channel": "Invitar a un usuario a unirse a este canal", "Invite_user_to_join_channel_all_from": "Invitar a todos los usuarios de [#channell] para unirse a este canal", "Invite_user_to_join_channel_all_to": "Invitar a todos los usuarios de este canal a unirse a [#channel]", diff --git a/packages/rocketchat-lib/server/methods/sendInvitationEmail.js b/packages/rocketchat-lib/server/methods/sendInvitationEmail.js index 247b5c11a129..97780e188c04 100644 --- a/packages/rocketchat-lib/server/methods/sendInvitationEmail.js +++ b/packages/rocketchat-lib/server/methods/sendInvitationEmail.js @@ -10,7 +10,7 @@ Meteor.startup(() => { }); Meteor.methods({ - sendInvitationEmail(emails, language) { + sendInvitationEmail(emails, language, realname) { check(emails, [String]); if (!Meteor.userId()) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { @@ -24,6 +24,13 @@ Meteor.methods({ } const validEmails = emails.filter(Mailer.checkAddressFormat); + let inviter; + if (!realname) { + inviter = Meteor.user().username; + } else { + inviter = realname; + } + const subject = RocketChat.settings.get('Invitation_Subject'); return validEmails.filter((email) => { try { @@ -35,7 +42,7 @@ Meteor.methods({ data: { email, Invite_Link:Meteor.runAsUser(Meteor.userId(), () => Meteor.call('getInviteLink')), - Username:Meteor.user().username, + Username:inviter, Avatar_Link:`${ RocketChat.settings.get('Site_Url').slice(0, -1) }${ getAvatarUrlFromUsername(Meteor.user().username) }`, }, lng: language, diff --git a/packages/rocketchat-lib/server/methods/sendInvitationSMS.js b/packages/rocketchat-lib/server/methods/sendInvitationSMS.js index 0e8896f5ddc8..b59ac17cad65 100644 --- a/packages/rocketchat-lib/server/methods/sendInvitationSMS.js +++ b/packages/rocketchat-lib/server/methods/sendInvitationSMS.js @@ -6,7 +6,7 @@ import _ from 'underscore'; const supportedLanguages = ['en', 'es']; Meteor.methods({ - sendInvitationSMS(phones, language) { + sendInvitationSMS(phones, language, realname) { const twilioService = RocketChat.SMS.getService('twilio'); if (!RocketChat.SMS.enabled || !twilioService) { throw new Meteor.Error('error-twilio-not-active', 'Twilio service not active', { @@ -41,6 +41,14 @@ Meteor.methods({ } })); const user = Meteor.user(); + + let inviter; + if (!realname) { + inviter = user.username; + } else { + inviter = realname; + } + let body; if (RocketChat.settings.get('Invitation_SMS_Customized')) { body = RocketChat.settings.get('Invitation_SMS_Customized_Body'); @@ -53,7 +61,7 @@ Meteor.methods({ lng, }); } - body = RocketChat.placeholders.replace(body); + body = RocketChat.placeholders.replace(body, { name:inviter }); validPhones.forEach((phone) => { try { twilioService.send(messageFrom, phone, body);