-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies (security fix) Fix lint errors
- Loading branch information
Showing
11 changed files
with
10,335 additions
and
5,075 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ module.exports = (logger, config) => { | |
}) | ||
// join rooms | ||
config.xmpp.rooms.forEach(function (room) { | ||
let occupantJid = room.id + '/' + address.local | ||
const occupantJid = room.id + '/' + address.local | ||
logger.debug(`Join room: ${room.id} ('${occupantJid}')`) | ||
const stanza = xml( | ||
'presence', { | ||
|
@@ -78,16 +78,16 @@ module.exports = (logger, config) => { | |
// not a message, do nothing | ||
return | ||
} | ||
let type = stanza.attrs.type | ||
const type = stanza.attrs.type | ||
switch (type) { | ||
case 'chat': | ||
case 'groupchat': | ||
let body = stanza.getChild('body') | ||
case 'groupchat': { | ||
const body = stanza.getChild('body') | ||
if (!body) { | ||
// empty body, do nothing | ||
return | ||
} | ||
let fromJid = jid(stanza.attrs.from) | ||
const fromJid = jid(stanza.attrs.from) | ||
// for chat, "to" and "replyTo" must be something like "[email protected]", "from" is local part "user" | ||
let to = this.jid.bare() | ||
let from = fromJid.local | ||
|
@@ -102,15 +102,15 @@ module.exports = (logger, config) => { | |
return | ||
} | ||
} | ||
let message = body.text() | ||
const message = body.text() | ||
// handle message delivery receipts for chat | ||
if (type === 'chat') { | ||
let request = stanza.getChild('request') | ||
const request = stanza.getChild('request') | ||
if (request && | ||
request.attrs.xmlns && | ||
request.attrs.xmlns === 'urn:xmpp:receipts' && | ||
stanza.attrs.id) { | ||
logger.debug(`Message delivery receipt is requested and will be processed`) | ||
logger.debug('Message delivery receipt is requested and will be processed') | ||
const receiptStanza = xml( | ||
'message', { | ||
to: fromJid | ||
|
@@ -127,7 +127,7 @@ module.exports = (logger, config) => { | |
} | ||
logger.info(`Incoming ${type} message from ${from} (${fromJid.toString()}) to ${to}`) | ||
logger.debug(`Message: "${message.replace(/\n|\r/g, ' ')}"`) | ||
let xmppHook = config.getXmppHookAction(to.toString()) | ||
const xmppHook = config.getXmppHookAction(to.toString()) | ||
if (!xmppHook) { | ||
logger.error(`There is no action for incoming ${type} message to: "${to}"`) | ||
return | ||
|
@@ -144,6 +144,7 @@ module.exports = (logger, config) => { | |
break | ||
} | ||
break | ||
} | ||
} | ||
}) | ||
|
||
|
Oops, something went wrong.