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
095e7add
Commit
095e7add
authored
Jun 23, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mam: Upgrade MAM support to version 2
parent
4536fdf0
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
79 deletions
+97
-79
CHANGES.md
CHANGES.md
+2
-0
spec/mam.js
spec/mam.js
+49
-54
src/converse-core.js
src/converse-core.js
+1
-1
src/converse-mam.js
src/converse-mam.js
+45
-24
No files found.
CHANGES.md
View file @
095e7add
...
...
@@ -2,6 +2,8 @@
## 3.1.0 (Unreleased)
-
Support for
[
XMPP-0313 Message Archive Management
](
https://xmpp.org/extensions/xep-0313.html
)
has been upgraded to version 2. [jcbrand]
-
New non-core plugin
`converse-singleton`
which ensures that no more than
one chat is visible at any given time. Used in the mobile build:
`converse-mobile.js`
and makes the unread messages counter possible there.
...
...
spec/mam.js
View file @
095e7add
This diff is collapsed.
Click to expand it.
src/converse-core.js
View file @
095e7add
...
...
@@ -192,7 +192,7 @@
Strophe
.
addNamespace
(
'
CSI
'
,
'
urn:xmpp:csi:0
'
);
Strophe
.
addNamespace
(
'
DELAY
'
,
'
urn:xmpp:delay
'
);
Strophe
.
addNamespace
(
'
HINTS
'
,
'
urn:xmpp:hints
'
);
Strophe
.
addNamespace
(
'
MAM
'
,
'
urn:xmpp:mam:
0
'
);
Strophe
.
addNamespace
(
'
MAM
'
,
'
urn:xmpp:mam:
2
'
);
Strophe
.
addNamespace
(
'
NICK
'
,
'
http://jabber.org/protocol/nick
'
);
Strophe
.
addNamespace
(
'
PUBSUB
'
,
'
http://jabber.org/protocol/pubsub
'
);
Strophe
.
addNamespace
(
'
ROSTERX
'
,
'
http://jabber.org/protocol/rosterx
'
);
...
...
src/converse-mam.js
View file @
095e7add
...
...
@@ -125,6 +125,23 @@
},
ChatRoomView
:
{
initialize
:
function
()
{
var
_converse
=
this
.
__super__
.
_converse
;
this
.
__super__
.
initialize
.
apply
(
this
,
arguments
);
this
.
model
.
on
(
'
change:mam_enabled
'
,
function
()
{
// Fetch messages again if we find out that mam has
// been enabled (because the first attempt would then
// have failed.
this
.
fetchArchivedMessages
({
'
before
'
:
''
,
// Page backwards from the most recent message
'
with
'
:
this
.
model
.
get
(
'
jid
'
),
'
max
'
:
_converse
.
archived_messages_page_size
});
this
.
model
.
save
({
'
mam_initialized
'
:
true
});
},
this
);
},
render
:
function
()
{
var
result
=
this
.
__super__
.
render
.
apply
(
this
,
arguments
);
if
(
!
this
.
disable_mam
)
{
...
...
@@ -150,7 +167,6 @@
* Then, upon receiving them, call onChatRoomMessage
* so that they are displayed inside it.
*/
var
that
=
this
;
var
_converse
=
this
.
__super__
.
_converse
;
if
(
!
_converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
_converse
.
log
(
...
...
@@ -162,6 +178,8 @@
return
;
}
this
.
addSpinner
();
var
that
=
this
;
_converse
.
api
.
archive
.
query
(
_
.
extend
(
options
,
{
'
groupchat
'
:
true
}),
function
(
messages
)
{
that
.
clearSpinner
();
...
...
@@ -216,18 +234,13 @@
callback
=
options
;
errback
=
callback
;
}
/*
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
_converse.log('This server does not support XEP-0313, Message Archive Management');
errback(null);
return;
}
*/
var
queryid
=
_converse
.
connection
.
getUniqueId
();
var
attrs
=
{
'
type
'
:
'
set
'
};
if
(
!
_
.
isUndefined
(
options
)
&&
options
.
groupchat
)
{
if
(
!
options
[
'
with
'
])
{
throw
new
Error
(
'
You need to specify a "with" value containing the chat room JID, when querying groupchat messages.
'
);
throw
new
Error
(
'
You need to specify a "with" value containing
'
+
'
the chat room JID, when querying groupchat messages.
'
);
}
attrs
.
to
=
options
[
'
with
'
];
}
...
...
@@ -258,23 +271,31 @@
}
}
if
(
_
.
isFunction
(
callback
))
{
_converse
.
connection
.
addHandler
(
function
(
message
)
{
var
$msg
=
$
(
message
),
rsm
,
$fin
=
$msg
.
find
(
'
fin[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
);
if
(
$fin
.
length
&&
$fin
.
attr
(
'
queryid
'
)
===
queryid
)
{
rsm
=
new
Strophe
.
RSM
({
xml
:
$fin
.
find
(
'
set
'
)[
0
]});
_
.
extend
(
rsm
,
_
.
pick
(
options
,
[
'
max
'
]));
_
.
extend
(
rsm
,
_
.
pick
(
options
,
MAM_ATTRIBUTES
));
var
message_handler
=
_converse
.
connection
.
addHandler
(
function
(
message
)
{
var
result
=
message
.
querySelector
(
'
result
'
);
if
(
!
_
.
isNull
(
result
)
&&
result
.
getAttribute
(
'
queryid
'
)
===
queryid
)
{
messages
.
push
(
message
);
}
return
true
;
},
Strophe
.
NS
.
MAM
);
_converse
.
connection
.
sendIQ
(
stanza
,
function
(
iq
)
{
_converse
.
connection
.
deleteHandler
(
message_handler
);
if
(
_
.
isFunction
(
callback
))
{
var
set
=
iq
.
querySelector
(
'
set
'
);
var
rsm
=
new
Strophe
.
RSM
({
xml
:
set
});
_
.
extend
(
rsm
,
_
.
pick
(
options
,
_
.
concat
(
MAM_ATTRIBUTES
,
[
'
max
'
])));
callback
(
messages
,
rsm
);
return
false
;
// We've received all messages, decommission this handler
}
else
if
(
queryid
===
$msg
.
find
(
'
result
'
).
attr
(
'
queryid
'
))
{
messages
.
push
(
message
);
}
return
true
;
},
Strophe
.
NS
.
MAM
);
}
_converse
.
connection
.
sendIQ
(
stanza
,
null
,
errback
,
_converse
.
message_archiving_timeout
);
},
function
()
{
_converse
.
connection
.
deleteHandler
(
message_handler
);
if
(
_
.
isFunction
(
errback
))
{
errback
.
apply
(
this
,
arguments
);
}
},
_converse
.
message_archiving_timeout
);
};
_
.
extend
(
_converse
.
api
,
{
...
...
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