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
02a055d3
Commit
02a055d3
authored
Aug 08, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Query user's JID for `mam:2` support, not the domain
parent
5e68364e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
22 deletions
+75
-22
CHANGES.md
CHANGES.md
+1
-0
spec/chatbox.js
spec/chatbox.js
+19
-7
src/converse-disco.js
src/converse-disco.js
+2
-1
src/converse-mam.js
src/converse-mam.js
+53
-14
No files found.
CHANGES.md
View file @
02a055d3
...
...
@@ -32,6 +32,7 @@
-
#866 Add babel in order to support ES2015 syntax [jcbrand]
#### Bugfixes:
-
The domain was queried for MAM:2 support, instead of the JID. [jcbrand]
-
Roster filter is not shown when all groups are collapsed. [jcbrand]
-
When filtering, contacts in closed groups appear. [jcbrand]
-
Room name wasn't being updated after changing it in the configuration form. [jcbrand]
...
...
spec/chatbox.js
View file @
02a055d3
...
...
@@ -1450,8 +1450,7 @@
});
}));
it
(
"
is sent when the user maximizes a minimized a chat box
"
,
mock
.
initConverseWithPromises
(
it
(
"
is sent when the user maximizes a minimized a chat box
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
...
...
@@ -1474,7 +1473,11 @@
},
300
);
}).
then
(
function
()
{
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
$stanza
=
$
(
_converse
.
connection
.
send
.
calls
.
argsFor
(
0
)[
0
].
tree
());
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
return
call
.
args
[
0
]
instanceof
Strophe
.
Builder
;
});
expect
(
calls
.
length
).
toBe
(
1
);
var
$stanza
=
$
(
calls
[
0
].
args
[
0
].
tree
());
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
3
);
expect
(
$stanza
.
children
().
get
(
0
).
tagName
).
toBe
(
'
active
'
);
...
...
@@ -1637,7 +1640,12 @@
},
500
);
}).
then
(
function
()
{
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
$stanza
=
$
(
_converse
.
connection
.
send
.
calls
.
argsFor
(
1
)[
0
].
tree
());
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
return
call
.
args
[
0
]
instanceof
Strophe
.
Builder
;
});
expect
(
calls
.
length
).
toBe
(
2
);
var
$stanza
=
$
(
calls
[
1
].
args
[
0
].
tree
());
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
3
);
expect
(
$stanza
.
children
().
get
(
0
).
tagName
).
toBe
(
'
paused
'
);
...
...
@@ -1776,7 +1784,11 @@
},
250
);
}).
then
(
function
()
{
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
$stanza
=
$
(
_converse
.
connection
.
send
.
calls
.
first
().
args
[
0
].
tree
());
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
return
call
.
args
[
0
]
instanceof
Strophe
.
Builder
;
});
expect
(
calls
.
length
).
toBe
(
2
);
var
$stanza
=
$
(
calls
[
0
].
args
[
0
].
tree
());
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
3
);
expect
(
$stanza
.
children
().
get
(
0
).
tagName
).
toBe
(
'
paused
'
);
...
...
src/converse-disco.js
View file @
02a055d3
...
...
@@ -105,6 +105,7 @@
'
from
'
:
stanza
.
getAttribute
(
'
from
'
)
});
});
this
.
trigger
(
'
featuresDiscovered
'
);
}
});
...
...
@@ -118,7 +119,7 @@
this
.
fetchEntities
().
then
(
_
.
partial
(
_converse
.
emit
,
'
discoInitialized
'
),
_
.
partial
(
_converse
.
emit
,
'
discoInitialized
'
)
);
)
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
;
},
fetchEntities
()
{
...
...
src/converse-mam.js
View file @
02a055d3
...
...
@@ -18,12 +18,38 @@
],
factory
);
}(
this
,
function
(
$
,
converse
)
{
"
use strict
"
;
const
{
Strophe
,
$iq
,
_
,
moment
}
=
converse
.
env
;
const
{
Promise
,
Strophe
,
$iq
,
_
,
moment
}
=
converse
.
env
;
const
RSM_ATTRIBUTES
=
[
'
max
'
,
'
first
'
,
'
last
'
,
'
after
'
,
'
before
'
,
'
index
'
,
'
count
'
];
// XEP-0313 Message Archive Management
const
MAM_ATTRIBUTES
=
[
'
with
'
,
'
start
'
,
'
end
'
];
function
checkMAMSupport
(
_converse
)
{
/* Returns a promise which resolves when MAM is supported
* for this user, or which rejects if not.
*/
return
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
).
then
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
function
fulfillPromise
(
entity
)
{
if
(
entity
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
resolve
(
true
);
}
else
{
resolve
(
false
);
}
}
let
entity
=
_converse
.
disco_entities
.
get
(
_converse
.
bare_jid
);
if
(
_
.
isUndefined
(
entity
))
{
entity
=
_converse
.
disco_entities
.
create
({
'
jid
'
:
_converse
.
bare_jid
});
entity
.
on
(
'
featuresDiscovered
'
,
_
.
partial
(
fulfillPromise
,
entity
));
}
else
{
fulfillPromise
(
entity
);
}
})
);
}
converse
.
plugins
.
add
(
'
converse-mam
'
,
{
overrides
:
{
...
...
@@ -51,18 +77,33 @@
fetchArchivedMessagesIfNecessary
()
{
/* Check if archived messages should be fetched, and if so, do so. */
const
{
_converse
}
=
this
.
__super__
,
entity
=
_converse
.
disco_entities
.
get
(
_converse
.
domain
),
server_supports_mam
=
entity
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
});
if
(
this
.
disable_mam
||
!
server_supports_mam
||
this
.
model
.
get
(
'
mam_initialized
'
))
{
if
(
this
.
disable_mam
||
this
.
model
.
get
(
'
mam_initialized
'
))
{
return
;
}
const
{
_converse
}
=
this
.
__super__
;
this
.
addSpinner
();
checkMAMSupport
(
_converse
).
then
(
(
supported
)
=>
{
// Success
if
(
supported
)
{
this
.
fetchArchivedMessages
();
}
else
{
this
.
clearSpinner
();
}
this
.
model
.
save
({
'
mam_initialized
'
:
true
});
},
()
=>
{
// Error
this
.
clearSpinner
();
_converse
.
log
(
"
Error or timeout while checking for MAM support
"
,
Strophe
.
LogLevel
.
ERROR
);
}
).
catch
((
msg
)
=>
{
this
.
clearSpinner
();
_converse
.
log
(
msg
,
Strophe
.
LogLevel
.
FATAL
);
});
},
fetchArchivedMessages
(
options
)
{
/* Fetch archived chat messages from the XMPP server.
...
...
@@ -71,7 +112,7 @@
* box, so that they are displayed inside it.
*/
const
{
_converse
}
=
this
.
__super__
;
if
(
!
_converse
.
disco_entities
.
get
(
_converse
.
domain
)
if
(
!
_converse
.
disco_entities
.
get
(
_converse
.
bare_jid
)
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
_converse
.
log
(
...
...
@@ -361,9 +402,7 @@
});
_converse
.
on
(
'
afterMessagesFetched
'
,
(
chatboxview
)
=>
{
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
)
.
then
(
chatboxview
.
fetchArchivedMessagesIfNecessary
.
bind
(
chatboxview
))
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
chatboxview
.
fetchArchivedMessagesIfNecessary
();
});
}
});
...
...
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