Skip to content

Commit

Permalink
More flexible invites.
Browse files Browse the repository at this point in the history
Also supportes now continued invites :)

Fixes #265
Relates candy-chat/candy-plugins#16

commit f5a751cfc78f4db2b5e02fd8b4da070a88e30d56
Author: Michael Weibel <[email protected]>
Date:   Fri Jul 11 07:56:18 2014 +0200

    Fix naming

commit 72dbba4
Author: Ben Langfeld <[email protected]>
Date:   Thu Jul 10 11:18:02 2014 -0300

    Support XEP-0249 Direct MUC Invitations

commit c263dee
Author: Ben Langfeld <[email protected]>
Date:   Thu Jul 10 11:04:15 2014 -0300

    Support invites as a continuation of a 1-on-1 thread

commit 85907cb
Author: Ben Langfeld <[email protected]>
Date:   Thu Jul 10 10:58:04 2014 -0300

    Support room passwords in MUC invites

commit bc2fa19
Author: Ben Langfeld <[email protected]>
Date:   Thu Jul 10 10:20:48 2014 -0300

    No need to look for this over and over

commit 1532df3
Author: Ben Langfeld <[email protected]>
Date:   Thu Jul 10 10:10:18 2014 -0300

    A mediated invite might be included in a normal message
  • Loading branch information
mweibel committed Jul 11, 2014
1 parent df951c9 commit ef6ffe4
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 33 deletions.
57 changes: 43 additions & 14 deletions candy.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion candy.bundle.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions candy.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion candy.min.map

Large diffs are not rendered by default.

69 changes: 54 additions & 15 deletions src/core/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,37 +253,76 @@ Candy.Core.Event = (function(self, Strophe, $) {

// Inspect the message type.
if (type === 'normal' || type === 'undefined') {
// It is an invite
if($(msg).find('invite').length > 0) {
var mediatedInvite = msg.find('invite'),
directInvite = msg.find('x[xmlns="jabber:x:conference"]');

if(mediatedInvite.length > 0) {
var passwordNode = msg.find('password'),
password = null,
continueNode = mediatedInvite.find('continue'),
continuedThread = null;

if(passwordNode) {
password = passwordNode.text();
}

if(continueNode) {
continuedThread = continueNode.attr('thread');
}

/** Event: candy:core:chat:invite
* Incoming chat invite for a MUC.
*
* Parameters:
* (String) roomJid - The room the invite is to
* (String) from - User JID that invite is from text
* (String) reason - Reason for invite [default: '']
* (String) password - Password for the room [default: null]
* (String) continuedThread - The thread ID if this is a continuation of a 1-on-1 chat [default: null]
*/
$(Candy).triggerHandler('candy:core:chat:invite', {
roomJid: fromJid,
from: $(msg).find('invite').attr('from') || 'undefined',
reason: $(msg).find('invite').find('reason').html() || ''
from: mediatedInvite.attr('from') || 'undefined',
reason: mediatedInvite.find('reason').html() || '',
password: password,
continuedThread: continuedThread
});
// It is not an invite
} else {
/** Event: candy:core:chat:message:normal
* Messages with the type attribute of normal or those
* that do not have the optional type attribute.
}

if(directInvite.length > 0) {
/** Event: candy:core:chat:invite
* Incoming chat invite for a MUC.
*
* Parameters:
* (String) type - Type of the message [default: message]
* (Object) message - Message object.
* (String) roomJid - The room the invite is to
* (String) from - User JID that invite is from text
* (String) reason - Reason for invite [default: '']
* (String) password - Password for the room [default: null]
* (String) continuedThread - The thread ID if this is a continuation of a 1-on-1 chat [default: null]
*/
// Detect message with type normal or with no type.
$(Candy).triggerHandler('candy:core:chat:message:normal', {
type: (type || 'normal'),
message: msg
$(Candy).triggerHandler('candy:core:chat:invite', {
roomJid: directInvite.attr('jid'),
from: fromJid,
reason: directInvite.attr('reason') || '',
password: directInvite.attr('password'),
continuedThread: directInvite.attr('thread')
});
}

/** Event: candy:core:chat:message:normal
* Messages with the type attribute of normal or those
* that do not have the optional type attribute.
*
* Parameters:
* (String) type - Type of the message [default: message]
* (Object) message - Message object.
*/
// Detect message with type normal or with no type.
$(Candy).triggerHandler('candy:core:chat:message:normal', {
type: (type || 'normal'),
message: msg
});

return true;
} else if (type !== 'groupchat' && type !== 'chat' && type !== 'error' && type !== 'headline') {
/** Event: candy:core:chat:message:other
Expand Down

0 comments on commit ef6ffe4

Please sign in to comment.