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
a0d344c7
Commit
a0d344c7
authored
Jul 11, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add better support for the results from a MAM query.
updates #306
parent
7437cf2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
7 deletions
+38
-7
converse.js
converse.js
+38
-7
No files found.
converse.js
View file @
a0d344c7
...
...
@@ -542,8 +542,42 @@
converse
.
connection
.
send
(
pres
);
};
this
.
onMAMQueryResult
=
function
(
iq
,
queryid
,
callback
)
{
/* Handle the IQ stanza and potential message stanzas returned as
* a result of a MAM (XEP-0313) query.
*
* Parameters:
* (XMLElement) iq - The IQ stanza returned from the XMPP server.
* (String) queryid - A unique ID sent with the MAM query.
* (Function) callback - A function to call whenever we receive query-relevant stanza.
*/
converse
.
connection
.
addHandler
(
function
(
message
)
{
var
rsm
,
$msg
=
$
(
message
);
var
$fin
=
$msg
.
find
(
'
fin[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
);
if
(
$fin
.
length
)
{
rsm
=
new
Strophe
.
RSM
({
xml
:
$fin
.
find
(
'
set
'
)[
0
]});
callback
(
message
,
rsm
);
return
false
;
// We've received all messages, decommission this handler
}
if
(
typeof
callback
==
"
function
"
)
{
if
(
queryid
==
$msg
.
find
(
'
result[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
).
attr
(
'
queryid
'
))
{
callback
(
message
);
}
return
true
;
}
else
{
return
false
;
// There's no callback, so no use in continuing this handler.
}
},
null
,
'
message
'
);
if
(
typeof
callback
==
"
function
"
)
{
return
callback
.
apply
(
arguments
);
}
};
this
.
getVCard
=
function
(
jid
,
callback
,
errback
)
{
/* Request the VCard of another user.
*
* Parameters:
* (String) jid - The Jabber ID of the user whose VCard is being requested.
* (Function) callback - A function to call once the VCard is returned
...
...
@@ -6128,7 +6162,8 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
throw
new
Error
(
'
This server does not support XEP-0313, Message Archive Management
'
);
}
var
stanza
=
$iq
({
'
type
'
:
'
set
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
queryid
'
:
converse
.
connection
.
getUniqueId
()});
var
queryid
=
converse
.
connection
.
getUniqueId
();
var
stanza
=
$iq
({
'
type
'
:
'
set
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MAM
,
'
queryid
'
:
queryid
});
if
(
typeof
options
!=
"
undefined
"
)
{
stanza
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
jabber:x:data
'
})
.
c
(
'
field
'
,
{
'
var
'
:
'
FORM_TYPE
'
})
...
...
@@ -6152,11 +6187,7 @@
stanza
.
cnode
(
new
Strophe
.
RSM
(
options
).
toXML
());
}
}
converse
.
connection
.
sendIQ
(
stanza
,
function
(
iq
)
{
debugger
;
var
rsm
=
new
Strophe
.
RSM
({
xml
:
iq
.
getElementsByTagName
(
'
set
'
)[
0
]});
return
_
.
bind
(
callback
,
this
,
arguments
)(
rsm
);
},
errback
);
converse
.
connection
.
sendIQ
(
stanza
,
_
.
partial
(
converse
.
onMAMQueryResult
,
_
,
queryid
,
callback
),
errback
);
}
},
'
rooms
'
:
{
...
...
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