Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
01f576e5
Commit
01f576e5
authored
Jun 24, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return all rooms or private chat when caling `get` without arguments
parent
be122af3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
+22
-8
docs/source/development.rst
docs/source/development.rst
+3
-3
src/converse-api.js
src/converse-api.js
+9
-2
src/converse-muc.js
src/converse-muc.js
+10
-3
No files found.
docs/source/development.rst
View file @
01f576e5
...
...
@@ -572,6 +572,8 @@ You may also provide the fullname. If not present, we use the jid as fullname:
The "chats" grouping
--------------------
Note, for MUC chat rooms, you need to use the "rooms" grouping instead.
get
~~~
...
...
@@ -653,12 +655,10 @@ get
Returns an object representing a multi user chat box (room).
It takes 3 parameters:
* the room JID
* the room JID
(if not specified, all rooms will be returned).
* the user's nickname (if not specified, the node part of the user's JID will be used).
* boolean, indicating whether the room should be created if not found (default: `false`)
The last two parameters are optional.
.. code-block:: javascript
var nick = 'dread-pirate-roberts';
...
...
src/converse-api.js
View file @
01f576e5
...
...
@@ -128,8 +128,15 @@
},
'
get
'
:
function
(
jids
)
{
if
(
typeof
jids
===
"
undefined
"
)
{
converse
.
log
(
"
chats.get: You need to provide at least one JID
"
,
"
error
"
);
return
null
;
var
result
=
[];
converse
.
chatboxes
.
each
(
function
(
chatbox
)
{
// FIXME: Leaky abstraction from MUC. We need to add a
// base type for chat boxes, and check for that.
if
(
chatbox
.
get
(
'
type
'
)
!==
'
chatroom
'
)
{
result
.
push
(
converse
.
wrappedChatBox
(
chatbox
));
}
});
return
result
;
}
else
if
(
typeof
jids
===
"
string
"
)
{
return
converse
.
wrappedChatBox
(
converse
.
chatboxes
.
getChatBox
(
jids
,
true
));
}
...
...
src/converse-muc.js
View file @
01f576e5
...
...
@@ -1432,13 +1432,20 @@
return
_
.
map
(
jids
,
_
.
partial
(
_transform
,
_
,
nick
,
fetcher
));
},
'
get
'
:
function
(
jids
,
nick
,
create
)
{
if
(
typeof
jids
===
"
undefined
"
)
{
var
result
=
[];
converse
.
chatboxes
.
each
(
function
(
chatbox
)
{
if
(
chatbox
.
get
(
'
type
'
)
===
'
chatroom
'
)
{
result
.
push
(
converse
.
wrappedChatBox
(
chatbox
));
}
});
return
result
;
}
var
fetcher
=
_
.
partial
(
converse
.
chatboxviews
.
getChatBox
.
bind
(
converse
.
chatboxviews
),
_
,
create
);
if
(
!
nick
)
{
nick
=
Strophe
.
getNodeFromJid
(
converse
.
bare_jid
);
}
if
(
typeof
jids
===
"
undefined
"
)
{
throw
new
TypeError
(
"
rooms.get: You need to provide at least one JID
"
);
}
else
if
(
typeof
jids
===
"
string
"
)
{
if
(
typeof
jids
===
"
string
"
)
{
return
_transform
(
jids
,
nick
,
fetcher
);
}
return
_
.
map
(
jids
,
_
.
partial
(
_transform
,
_
,
nick
,
fetcher
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment