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
dcd14071
Commit
dcd14071
authored
Jan 13, 2021
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New config setting mam_request_all_pages
parent
b5b35a97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
17 deletions
+47
-17
CHANGES.md
CHANGES.md
+1
-0
docs/source/configuration.rst
docs/source/configuration.rst
+24
-0
src/headless/plugins/mam/index.js
src/headless/plugins/mam/index.js
+1
-0
src/headless/plugins/mam/utils.js
src/headless/plugins/mam/utils.js
+21
-17
No files found.
CHANGES.md
View file @
dcd14071
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
-
File structure reordering: All plugins are now in
`./plugins`
folders.
-
File structure reordering: All plugins are now in
`./plugins`
folders.
-
New configuration setting:
[
show_tab_notifications
](
https://conversejs.org/docs/html/configuration.html#show-tab-notifications
)
-
New configuration setting:
[
show_tab_notifications
](
https://conversejs.org/docs/html/configuration.html#show-tab-notifications
)
-
New configuration setting:
[
muc_clear_messages_on_leave
](
https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave
)
-
New configuration setting:
[
muc_clear_messages_on_leave
](
https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave
)
-
#1823: New config options
[
mam_request_all_pages
](
https://conversejs.org/docs/html/configuration.html#mam-request-all-pages
)
-
Use the MUC stanza id when sending XEP-0333 markers
-
Use the MUC stanza id when sending XEP-0333 markers
### Breaking Changes
### Breaking Changes
...
...
docs/source/configuration.rst
View file @
dcd14071
...
@@ -1071,6 +1071,30 @@ VCard is taken, and if that is not set but `muc_nickname_from_jid`_ is set to
...
@@ -1071,6 +1071,30 @@ VCard is taken, and if that is not set but `muc_nickname_from_jid`_ is set to
If no nickame value is found, then an error will be raised.
If no nickame value is found, then an error will be raised.
mam_request_all_pages
---------------------
* Default: ``true``
When requesting messages from the archive, Converse will ask only for messages
newer than the most recent cached message.
When there are many archived messages since that one, the returned results will
be broken up in to pages, set by `archived_messages_page_size`_.
By default Converse will request all the pages until all messages have been
fetched, however for large archives this can slow things down dramatically.
This setting turns the paging off, and Converse will only fetch the latest
page.
.. note::
If paging is turned off, there will appear gaps in the message history.
Converse currently doesn't yet have a way to inform the user of these gaps or
to let them be filled.
muc_hats
muc_hats
--------
--------
...
...
src/headless/plugins/mam/index.js
View file @
dcd14071
...
@@ -24,6 +24,7 @@ converse.plugins.add('converse-mam', {
...
@@ -24,6 +24,7 @@ converse.plugins.add('converse-mam', {
initialize
()
{
initialize
()
{
api
.
settings
.
extend
({
api
.
settings
.
extend
({
archived_messages_page_size
:
'
50
'
,
archived_messages_page_size
:
'
50
'
,
mam_request_all_pages
:
true
,
message_archiving
:
undefined
,
// Supported values are 'always', 'never', 'roster' (https://xmpp.org/extensions/xep-0313.html#prefs)
message_archiving
:
undefined
,
// Supported values are 'always', 'never', 'roster' (https://xmpp.org/extensions/xep-0313.html#prefs)
message_archiving_timeout
:
20000
// Time (in milliseconds) to wait before aborting MAM request
message_archiving_timeout
:
20000
// Time (in milliseconds) to wait before aborting MAM request
});
});
...
...
src/headless/plugins/mam/utils.js
View file @
dcd14071
...
@@ -73,7 +73,7 @@ export function preMUCJoinMAMFetch (muc) {
...
@@ -73,7 +73,7 @@ export function preMUCJoinMAMFetch (muc) {
muc
.
save
({
'
prejoin_mam_fetched
'
:
true
});
muc
.
save
({
'
prejoin_mam_fetched
'
:
true
});
}
}
export
async
function
handleMAMResult
(
model
,
result
,
query
,
options
,
page_direction
)
{
export
async
function
handleMAMResult
(
model
,
result
,
query
,
options
,
should_page
)
{
await
api
.
emojis
.
initialize
();
await
api
.
emojis
.
initialize
();
const
is_muc
=
model
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
;
const
is_muc
=
model
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
;
result
.
messages
=
result
.
messages
.
map
(
s
=>
result
.
messages
=
result
.
messages
.
map
(
s
=>
...
@@ -91,7 +91,7 @@ export async function handleMAMResult (model, result, query, options, page_direc
...
@@ -91,7 +91,7 @@ export async function handleMAMResult (model, result, query, options, page_direc
result
.
messages
.
forEach
(
m
=>
model
.
queueMessage
(
m
));
result
.
messages
.
forEach
(
m
=>
model
.
queueMessage
(
m
));
if
(
result
.
error
)
{
if
(
result
.
error
)
{
const
event_id
=
(
result
.
error
.
retry_event_id
=
u
.
getUniqueId
());
const
event_id
=
(
result
.
error
.
retry_event_id
=
u
.
getUniqueId
());
api
.
listen
.
once
(
event_id
,
()
=>
fetchArchivedMessages
(
model
,
options
,
page_direction
));
api
.
listen
.
once
(
event_id
,
()
=>
fetchArchivedMessages
(
model
,
options
,
should_page
));
model
.
createMessageFromError
(
result
.
error
);
model
.
createMessageFromError
(
result
.
error
);
}
}
}
}
...
@@ -112,10 +112,10 @@ export async function handleMAMResult (model, result, query, options, page_direc
...
@@ -112,10 +112,10 @@ export async function handleMAMResult (model, result, query, options, page_direc
* @param { string } [options.with] - The JID of the entity with
* @param { string } [options.with] - The JID of the entity with
* which messages were exchanged.
* which messages were exchanged.
* @param { boolean } [options.groupchat] - True if archive in groupchat.
* @param { boolean } [options.groupchat] - True if archive in groupchat.
* @param { ('forwards'|'backwards'
)} [page_direction
] - Determines whether this function should
* @param { ('forwards'|'backwards'
|null)} [should_page=null
] - Determines whether this function should
* recursively page through the entire result set if a limited number of results were returned.
* recursively page through the entire result set if a limited number of results were returned.
*/
*/
export
async
function
fetchArchivedMessages
(
model
,
options
=
{},
page_direction
)
{
export
async
function
fetchArchivedMessages
(
model
,
options
=
{},
should_page
=
null
)
{
if
(
model
.
disable_mam
)
{
if
(
model
.
disable_mam
)
{
return
;
return
;
}
}
...
@@ -135,19 +135,21 @@ export async function fetchArchivedMessages (model, options = {}, page_direction
...
@@ -135,19 +135,21 @@ export async function fetchArchivedMessages (model, options = {}, page_direction
);
);
const
result
=
await
api
.
archive
.
query
(
query
);
const
result
=
await
api
.
archive
.
query
(
query
);
await
handleMAMResult
(
model
,
result
,
query
,
options
,
page_direction
);
await
handleMAMResult
(
model
,
result
,
query
,
options
,
should_page
);
if
(
page_direction
&&
result
.
rsm
&&
!
result
.
complete
)
{
if
(
result
.
rsm
&&
!
result
.
complete
)
{
if
(
page_direction
===
'
forwards
'
)
{
if
(
should_page
)
{
options
=
result
.
rsm
.
next
(
max
,
options
.
before
).
query
;
if
(
should_page
===
'
forwards
'
)
{
}
else
if
(
page_direction
===
'
backwards
'
)
{
options
=
result
.
rsm
.
next
(
max
,
options
.
before
).
query
;
options
=
result
.
rsm
.
previous
(
max
,
options
.
after
).
query
;
}
else
if
(
should_page
===
'
backwards
'
)
{
options
=
result
.
rsm
.
previous
(
max
,
options
.
after
).
query
;
}
return
fetchArchivedMessages
(
model
,
options
,
should_page
);
}
else
{
// TODO: Add a special kind of message which will
// render as a link to fetch further messages, either
// to fetch older messages or to fill in a gap.
}
}
return
fetchArchivedMessages
(
model
,
options
,
page_direction
);
}
else
{
// TODO: Add a special kind of message which will
// render as a link to fetch further messages, either
// to fetch older messages or to fill in a gap.
}
}
}
}
...
@@ -159,16 +161,18 @@ export function fetchNewestMessages (model) {
...
@@ -159,16 +161,18 @@ export function fetchNewestMessages (model) {
if
(
model
.
disable_mam
)
{
if
(
model
.
disable_mam
)
{
return
;
return
;
}
}
const
most_recent_msg
=
model
.
getMostRecentMessage
();
const
most_recent_msg
=
model
.
getMostRecentMessage
();
// if clear_messages_on_reconnection is true, than any recent messages
// if clear_messages_on_reconnection is true, than any recent messages
// must have been received *after* connection and we instead must query
// must have been received *after* connection and we instead must query
// for earlier messages
// for earlier messages
if
(
most_recent_msg
&&
!
api
.
settings
.
get
(
'
clear_messages_on_reconnection
'
))
{
if
(
most_recent_msg
&&
!
api
.
settings
.
get
(
'
clear_messages_on_reconnection
'
))
{
const
should_page
=
api
.
settings
.
get
(
'
mam_request_all_pages
'
);
const
stanza_id
=
most_recent_msg
.
get
(
`stanza_id
${
model
.
get
(
'
jid
'
)}
`
);
const
stanza_id
=
most_recent_msg
.
get
(
`stanza_id
${
model
.
get
(
'
jid
'
)}
`
);
if
(
stanza_id
)
{
if
(
stanza_id
)
{
fetchArchivedMessages
(
model
,
{
'
after
'
:
stanza_id
},
'
forwards
'
);
fetchArchivedMessages
(
model
,
{
'
after
'
:
stanza_id
},
should_page
?
'
forwards
'
:
null
);
}
else
{
}
else
{
fetchArchivedMessages
(
model
,
{
'
start
'
:
most_recent_msg
.
get
(
'
time
'
)
},
'
forwards
'
);
fetchArchivedMessages
(
model
,
{
'
start
'
:
most_recent_msg
.
get
(
'
time
'
)
},
should_page
?
'
forwards
'
:
null
);
}
}
}
else
{
}
else
{
fetchArchivedMessages
(
model
,
{
'
before
'
:
''
});
fetchArchivedMessages
(
model
,
{
'
before
'
:
''
});
...
...
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