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
6d975264
Commit
6d975264
authored
Oct 01, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace lodash methods with native ones
filter find has isEmpty isString isUndefined noop reject uniq
parent
efd4e503
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
68 additions
and
73 deletions
+68
-73
src/components/emoji-picker.js
src/components/emoji-picker.js
+2
-2
src/converse-chatview.js
src/converse-chatview.js
+2
-2
src/converse-modal.js
src/converse-modal.js
+3
-4
src/converse-muc-views.js
src/converse-muc-views.js
+3
-3
src/converse-push.js
src/converse-push.js
+2
-3
src/converse-rosterview.js
src/converse-rosterview.js
+4
-4
src/headless/connection.js
src/headless/connection.js
+3
-3
src/headless/converse-caps.js
src/headless/converse-caps.js
+1
-2
src/headless/converse-chat.js
src/headless/converse-chat.js
+5
-5
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+2
-3
src/headless/converse-core.js
src/headless/converse-core.js
+3
-3
src/headless/converse-disco.js
src/headless/converse-disco.js
+2
-2
src/headless/converse-emoji.js
src/headless/converse-emoji.js
+6
-4
src/headless/converse-headlines.js
src/headless/converse-headlines.js
+1
-2
src/headless/converse-muc.js
src/headless/converse-muc.js
+10
-10
src/headless/converse-roster.js
src/headless/converse-roster.js
+6
-7
src/headless/converse-status.js
src/headless/converse-status.js
+4
-4
src/headless/converse-vcard.js
src/headless/converse-vcard.js
+4
-5
src/headless/utils/core.js
src/headless/utils/core.js
+4
-4
src/templates/directives/body.js
src/templates/directives/body.js
+1
-1
No files found.
src/components/emoji-picker.js
View file @
6d975264
...
@@ -4,7 +4,7 @@ import { BaseDropdown } from "./dropdown.js";
...
@@ -4,7 +4,7 @@ import { BaseDropdown } from "./dropdown.js";
import
{
CustomElement
}
from
'
./element.js
'
;
import
{
CustomElement
}
from
'
./element.js
'
;
import
{
__
}
from
'
../i18n
'
;
import
{
__
}
from
'
../i18n
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
debounce
,
find
}
from
"
lodash-es
"
;
import
{
debounce
}
from
"
lodash-es
"
;
import
{
html
}
from
"
lit-element
"
;
import
{
html
}
from
"
lit-element
"
;
import
{
tpl_emoji_picker
}
from
"
../templates/emoji_picker.js
"
;
import
{
tpl_emoji_picker
}
from
"
../templates/emoji_picker.js
"
;
import
{
until
}
from
'
lit-html/directives/until.js
'
;
import
{
until
}
from
'
lit-html/directives/until.js
'
;
...
@@ -177,7 +177,7 @@ export default class EmojiPicker extends CustomElement {
...
@@ -177,7 +177,7 @@ export default class EmojiPicker extends CustomElement {
if
(
ev
.
keyCode
===
converse
.
keycodes
.
TAB
)
{
if
(
ev
.
keyCode
===
converse
.
keycodes
.
TAB
)
{
if
(
ev
.
target
.
value
)
{
if
(
ev
.
target
.
value
)
{
ev
.
preventDefault
();
ev
.
preventDefault
();
const
match
=
find
(
converse
.
emojis
.
shortnames
,
sn
=>
_converse
.
FILTER_CONTAINS
(
sn
,
ev
.
target
.
value
));
const
match
=
converse
.
emojis
.
shortnames
.
find
(
sn
=>
_converse
.
FILTER_CONTAINS
(
sn
,
ev
.
target
.
value
));
match
&&
this
.
model
.
set
({
'
query
'
:
match
});
match
&&
this
.
model
.
set
({
'
query
'
:
match
});
}
else
if
(
!
this
.
navigator
.
enabled
)
{
}
else
if
(
!
this
.
navigator
.
enabled
)
{
this
.
enableArrowNavigation
(
ev
);
this
.
enableArrowNavigation
(
ev
);
...
...
src/converse-chatview.js
View file @
6d975264
...
@@ -19,7 +19,7 @@ import { BootstrapModal } from "./converse-modal.js";
...
@@ -19,7 +19,7 @@ import { BootstrapModal } from "./converse-modal.js";
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
debounce
,
isString
}
from
"
lodash-es
"
;
import
{
debounce
}
from
"
lodash-es
"
;
import
{
html
,
render
}
from
"
lit-html
"
;
import
{
html
,
render
}
from
"
lit-html
"
;
...
@@ -1216,7 +1216,7 @@ converse.plugins.add('converse-chatview', {
...
@@ -1216,7 +1216,7 @@ converse.plugins.add('converse-chatview', {
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
return
Object
.
values
(
_converse
.
chatboxviews
.
getAll
());
return
Object
.
values
(
_converse
.
chatboxviews
.
getAll
());
}
}
if
(
isString
(
jids
)
)
{
if
(
typeof
jids
===
'
string
'
)
{
return
_converse
.
chatboxviews
.
get
(
jids
);
return
_converse
.
chatboxviews
.
get
(
jids
);
}
}
return
jids
.
map
(
jid
=>
_converse
.
chatboxviews
.
get
(
jid
));
return
jids
.
map
(
jid
=>
_converse
.
chatboxviews
.
get
(
jid
));
...
...
src/converse-modal.js
View file @
6d975264
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
*/
*/
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
isString
}
from
"
lodash-es
"
;
import
{
render
}
from
'
lit-html
'
;
import
{
render
}
from
'
lit-html
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
__
}
from
'
./i18n
'
;
import
bootstrap
from
"
bootstrap.native
"
;
import
bootstrap
from
"
bootstrap.native
"
;
...
@@ -186,7 +185,7 @@ converse.plugins.add('converse-modal', {
...
@@ -186,7 +185,7 @@ converse.plugins.add('converse-modal', {
* filled in fields or `false` if the confirm dialog was closed or canceled.
* filled in fields or `false` if the confirm dialog was closed or canceled.
*/
*/
async
confirm
(
title
,
messages
=
[],
fields
=
[])
{
async
confirm
(
title
,
messages
=
[],
fields
=
[])
{
if
(
isString
(
messages
)
)
{
if
(
typeof
messages
===
'
string
'
)
{
messages
=
[
messages
];
messages
=
[
messages
];
}
}
const
model
=
new
Model
({
title
,
messages
,
fields
,
'
type
'
:
'
confirm
'
})
const
model
=
new
Model
({
title
,
messages
,
fields
,
'
type
'
:
'
confirm
'
})
...
@@ -212,7 +211,7 @@ converse.plugins.add('converse-modal', {
...
@@ -212,7 +211,7 @@ converse.plugins.add('converse-modal', {
* user or `false` if the user canceled the prompt.
* user or `false` if the user canceled the prompt.
*/
*/
async
prompt
(
title
,
messages
=
[],
placeholder
=
''
)
{
async
prompt
(
title
,
messages
=
[],
placeholder
=
''
)
{
if
(
isString
(
messages
)
)
{
if
(
typeof
messages
===
'
string
'
)
{
messages
=
[
messages
];
messages
=
[
messages
];
}
}
const
model
=
new
Model
({
const
model
=
new
Model
({
...
@@ -244,7 +243,7 @@ converse.plugins.add('converse-modal', {
...
@@ -244,7 +243,7 @@ converse.plugins.add('converse-modal', {
* @param { (String[]|String) } messages - The alert text to show to the user.
* @param { (String[]|String) } messages - The alert text to show to the user.
*/
*/
alert
(
type
,
title
,
messages
)
{
alert
(
type
,
title
,
messages
)
{
if
(
isString
(
messages
)
)
{
if
(
typeof
messages
===
'
string
'
)
{
messages
=
[
messages
];
messages
=
[
messages
];
}
}
let
level
;
let
level
;
...
...
src/converse-muc-views.js
View file @
6d975264
...
@@ -28,7 +28,7 @@ import { Model } from '@converse/skeletor/src/model.js';
...
@@ -28,7 +28,7 @@ import { Model } from '@converse/skeletor/src/model.js';
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
debounce
,
isString
,
isUndefined
}
from
"
lodash-es
"
;
import
{
debounce
}
from
"
lodash-es
"
;
import
{
render
}
from
"
lit-html
"
;
import
{
render
}
from
"
lit-html
"
;
const
{
Strophe
,
sizzle
,
$pres
}
=
converse
.
env
;
const
{
Strophe
,
sizzle
,
$pres
}
=
converse
.
env
;
...
@@ -504,7 +504,7 @@ export const ChatRoomView = ChatBoxView.extend({
...
@@ -504,7 +504,7 @@ export const ChatRoomView = ChatBoxView.extend({
if
(
!
this
.
verifyRoles
([
'
moderator
'
]))
{
if
(
!
this
.
verifyRoles
([
'
moderator
'
]))
{
return
;
return
;
}
}
if
(
isUndefined
(
this
.
model
.
modtools_modal
)
)
{
if
(
typeof
this
.
model
.
modtools_modal
===
'
undefined
'
)
{
const
model
=
new
Model
({
'
affiliation
'
:
affiliation
});
const
model
=
new
Model
({
'
affiliation
'
:
affiliation
});
this
.
modtools_modal
=
new
ModeratorToolsModal
({
model
,
_converse
,
'
chatroomview
'
:
this
});
this
.
modtools_modal
=
new
ModeratorToolsModal
({
model
,
_converse
,
'
chatroomview
'
:
this
});
}
else
{
}
else
{
...
@@ -1736,7 +1736,7 @@ converse.plugins.add('converse-muc-views', {
...
@@ -1736,7 +1736,7 @@ converse.plugins.add('converse-muc-views', {
let
views
;
let
views
;
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
views
=
_converse
.
chatboxviews
;
views
=
_converse
.
chatboxviews
;
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
views
=
[
_converse
.
chatboxviews
.
get
(
jids
)].
filter
(
v
=>
v
);
views
=
[
_converse
.
chatboxviews
.
get
(
jids
)].
filter
(
v
=>
v
);
}
else
if
(
Array
.
isArray
(
jids
))
{
}
else
if
(
Array
.
isArray
(
jids
))
{
views
=
jids
.
map
(
jid
=>
_converse
.
chatboxviews
.
get
(
jid
));
views
=
jids
.
map
(
jid
=>
_converse
.
chatboxviews
.
get
(
jid
));
...
...
src/converse-push.js
View file @
6d975264
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
* @license Mozilla Public License (MPLv2)
* @license Mozilla Public License (MPLv2)
*/
*/
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
filter
,
reject
}
from
'
lodash-es
'
;
import
log
from
"
@converse/headless/log
"
;
import
log
from
"
@converse/headless/log
"
;
const
{
Strophe
,
$iq
}
=
converse
.
env
;
const
{
Strophe
,
$iq
}
=
converse
.
env
;
...
@@ -95,8 +94,8 @@ converse.plugins.add('converse-push', {
...
@@ -95,8 +94,8 @@ converse.plugins.add('converse-push', {
if
(
push_enabled
.
includes
(
domain
))
{
if
(
push_enabled
.
includes
(
domain
))
{
return
;
return
;
}
}
const
enabled_services
=
reject
(
api
.
settings
.
get
(
'
push_app_servers
'
),
'
disable
'
);
const
enabled_services
=
api
.
settings
.
get
(
'
push_app_servers
'
).
filter
(
s
=>
!
s
.
disable
);
const
disabled_services
=
filter
(
api
.
settings
.
get
(
'
push_app_servers
'
),
'
disable
'
);
const
disabled_services
=
api
.
settings
.
get
(
'
push_app_servers
'
).
filter
(
s
=>
s
.
disable
);
const
enabled
=
enabled_services
.
map
(
s
=>
enablePushAppServer
(
domain
,
s
));
const
enabled
=
enabled_services
.
map
(
s
=>
enablePushAppServer
(
domain
,
s
));
const
disabled
=
disabled_services
.
map
(
s
=>
disablePushAppServer
(
domain
,
s
));
const
disabled
=
disabled_services
.
map
(
s
=>
disablePushAppServer
(
domain
,
s
));
try
{
try
{
...
...
src/converse-rosterview.js
View file @
6d975264
...
@@ -20,7 +20,7 @@ import { OrderedListView } from "@converse/skeletor/src/overview";
...
@@ -20,7 +20,7 @@ import { OrderedListView } from "@converse/skeletor/src/overview";
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
View
}
from
'
@converse/skeletor/src/view.js
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
__
}
from
'
./i18n
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
compact
,
debounce
,
has
,
isString
,
uniq
,
without
}
from
"
lodash-es
"
;
import
{
compact
,
debounce
,
has
,
without
}
from
"
lodash-es
"
;
const
{
Strophe
}
=
converse
.
env
;
const
{
Strophe
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -72,7 +72,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -72,7 +72,7 @@ converse.plugins.add('converse-rosterview', {
},
},
afterRender
()
{
afterRender
()
{
if
(
api
.
settings
.
get
(
'
xhr_user_search_url
'
)
&&
isString
(
api
.
settings
.
get
(
'
xhr_user_search_url
'
))
)
{
if
(
typeof
api
.
settings
.
get
(
'
xhr_user_search_url
'
)
===
'
string
'
)
{
this
.
initXHRAutoComplete
();
this
.
initXHRAutoComplete
();
}
else
{
}
else
{
this
.
initJIDAutoComplete
();
this
.
initJIDAutoComplete
();
...
@@ -89,7 +89,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -89,7 +89,7 @@ converse.plugins.add('converse-rosterview', {
this
.
jid_auto_complete
=
new
_converse
.
AutoComplete
(
el
,
{
this
.
jid_auto_complete
=
new
_converse
.
AutoComplete
(
el
,
{
'
data
'
:
(
text
,
input
)
=>
`
${
input
.
slice
(
0
,
input
.
indexOf
(
"
@
"
))}
@
${
text
}
`
,
'
data
'
:
(
text
,
input
)
=>
`
${
input
.
slice
(
0
,
input
.
indexOf
(
"
@
"
))}
@
${
text
}
`
,
'
filter
'
:
_converse
.
FILTER_STARTSWITH
,
'
filter
'
:
_converse
.
FILTER_STARTSWITH
,
'
list
'
:
uniq
(
_converse
.
roster
.
map
(
item
=>
Strophe
.
getDomainFromJid
(
item
.
get
(
'
jid
'
))))
'
list
'
:
[...
new
Set
(
_converse
.
roster
.
map
(
item
=>
Strophe
.
getDomainFromJid
(
item
.
get
(
'
jid
'
))))]
});
});
},
},
...
@@ -172,7 +172,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -172,7 +172,7 @@ converse.plugins.add('converse-rosterview', {
const
data
=
new
FormData
(
ev
.
target
),
const
data
=
new
FormData
(
ev
.
target
),
jid
=
(
data
.
get
(
'
jid
'
)
||
''
).
trim
();
jid
=
(
data
.
get
(
'
jid
'
)
||
''
).
trim
();
if
(
!
jid
&&
api
.
settings
.
get
(
'
xhr_user_search_url
'
)
&&
isString
(
api
.
settings
.
get
(
'
xhr_user_search_url
'
))
)
{
if
(
!
jid
&&
typeof
api
.
settings
.
get
(
'
xhr_user_search_url
'
)
===
'
string
'
)
{
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
const
input_el
=
this
.
el
.
querySelector
(
'
input[name="name"]
'
);
this
.
xhr
.
open
(
"
GET
"
,
`
${
api
.
settings
.
get
(
'
xhr_user_search_url
'
)}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
this
.
xhr
.
open
(
"
GET
"
,
`
${
api
.
settings
.
get
(
'
xhr_user_search_url
'
)}
q=
${
encodeURIComponent
(
input_el
.
value
)}
`
,
true
);
this
.
xhr
.
send
()
this
.
xhr
.
send
()
...
...
src/headless/connection.js
View file @
6d975264
...
@@ -3,7 +3,7 @@ import sizzle from 'sizzle';
...
@@ -3,7 +3,7 @@ import sizzle from 'sizzle';
import
u
from
'
@converse/headless/utils/core
'
;
import
u
from
'
@converse/headless/utils/core
'
;
import
{
Strophe
}
from
'
strophe.js/src/core
'
;
import
{
Strophe
}
from
'
strophe.js/src/core
'
;
import
{
_converse
,
api
,
clearSession
,
tearDown
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
clearSession
,
tearDown
}
from
"
./converse-core
"
;
import
{
debounce
,
isElement
,
noop
}
from
'
lodash
'
;
import
{
debounce
,
isElement
}
from
'
lodash
'
;
const
BOSH_WAIT
=
59
;
const
BOSH_WAIT
=
59
;
...
@@ -362,9 +362,9 @@ export class MockConnection extends Connection {
...
@@ -362,9 +362,9 @@ export class MockConnection extends Connection {
'
</session>
'
+
'
</session>
'
+
'
</stream:features>
'
).
firstChild
;
'
</stream:features>
'
).
firstChild
;
this
.
_proto
.
_processRequest
=
noop
;
this
.
_proto
.
_processRequest
=
()
=>
{}
;
this
.
_proto
.
_disconnect
=
()
=>
this
.
_onDisconnectTimeout
();
this
.
_proto
.
_disconnect
=
()
=>
this
.
_onDisconnectTimeout
();
this
.
_proto
.
_onDisconnectTimeout
=
noop
;
this
.
_proto
.
_onDisconnectTimeout
=
()
=>
{}
;
this
.
_proto
.
_connect
=
()
=>
{
this
.
_proto
.
_connect
=
()
=>
{
this
.
connected
=
true
;
this
.
connected
=
true
;
this
.
mock
=
true
;
this
.
mock
=
true
;
...
...
src/headless/converse-caps.js
View file @
6d975264
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
*/
*/
import
SHA1
from
'
strophe.js/src/sha1
'
;
import
SHA1
from
'
strophe.js/src/sha1
'
;
import
{
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
get
}
from
"
lodash-es
"
;
const
{
Strophe
,
$build
}
=
converse
.
env
;
const
{
Strophe
,
$build
}
=
converse
.
env
;
...
@@ -25,7 +24,7 @@ function generateVerificationString (_converse) {
...
@@ -25,7 +24,7 @@ function generateVerificationString (_converse) {
propertySort
(
identities
,
"
lang
"
);
propertySort
(
identities
,
"
lang
"
);
}
}
let
S
=
identities
.
reduce
((
result
,
id
)
=>
`
${
result
}${
id
.
category
}
/
${
id
.
type
}
/
${
get
(
id
,
'
lang
'
,
''
)
}
/
${
id
.
name
}
<`
,
""
);
let
S
=
identities
.
reduce
((
result
,
id
)
=>
`
${
result
}${
id
.
category
}
/
${
id
.
type
}
/
${
id
?.
lang
??
''
}
/${id.name}<`, ""
)
;
features
.
sort
();
features
.
sort
();
S
=
features
.
reduce
((
result
,
feature
)
=>
`
${
result
}${
feature
}
<`
,
S
);
S
=
features
.
reduce
((
result
,
feature
)
=>
`
${
result
}${
feature
}
<`
,
S
);
return
SHA1
.
b64_sha1
(
S
);
return
SHA1
.
b64_sha1
(
S
);
...
...
src/headless/converse-chat.js
View file @
6d975264
...
@@ -9,7 +9,7 @@ import st from "./utils/stanza";
...
@@ -9,7 +9,7 @@ import st from "./utils/stanza";
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
find
,
isMatch
,
isObject
,
isString
,
pick
}
from
"
lodash-es
"
;
import
{
find
,
isMatch
,
isObject
,
pick
}
from
"
lodash-es
"
;
const
{
$msg
,
Strophe
,
sizzle
,
utils
}
=
converse
.
env
;
const
{
$msg
,
Strophe
,
sizzle
,
utils
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -1282,7 +1282,7 @@ converse.plugins.add('converse-chat', {
...
@@ -1282,7 +1282,7 @@ converse.plugins.add('converse-chat', {
if
(
_converse
.
chatboxes
.
where
({
'
jid
'
:
jid
}).
length
)
{
if
(
_converse
.
chatboxes
.
where
({
'
jid
'
:
jid
}).
length
)
{
return
;
return
;
}
}
if
(
isString
(
jid
)
)
{
if
(
typeof
jid
===
'
string
'
)
{
api
.
chats
.
open
(
jid
);
api
.
chats
.
open
(
jid
);
}
else
{
}
else
{
log
.
error
(
'
Invalid jid criteria specified for "auto_join_private_chats"
'
);
log
.
error
(
'
Invalid jid criteria specified for "auto_join_private_chats"
'
);
...
@@ -1338,7 +1338,7 @@ converse.plugins.add('converse-chat', {
...
@@ -1338,7 +1338,7 @@ converse.plugins.add('converse-chat', {
* @param {object} [attrs] An object containing configuration attributes.
* @param {object} [attrs] An object containing configuration attributes.
*/
*/
async
create
(
jids
,
attrs
)
{
async
create
(
jids
,
attrs
)
{
if
(
isString
(
jids
)
)
{
if
(
typeof
jids
===
'
string
'
)
{
if
(
attrs
&&
!
attrs
?.
fullname
)
{
if
(
attrs
&&
!
attrs
?.
fullname
)
{
const
contact
=
await
api
.
contacts
.
get
(
jids
);
const
contact
=
await
api
.
contacts
.
get
(
jids
);
attrs
.
fullname
=
contact
?.
attributes
?.
fullname
;
attrs
.
fullname
=
contact
?.
attributes
?.
fullname
;
...
@@ -1402,7 +1402,7 @@ converse.plugins.add('converse-chat', {
...
@@ -1402,7 +1402,7 @@ converse.plugins.add('converse-chat', {
* });
* });
*/
*/
async
open
(
jids
,
attrs
,
force
)
{
async
open
(
jids
,
attrs
,
force
)
{
if
(
isString
(
jids
)
)
{
if
(
typeof
jids
===
'
string
'
)
{
const
chat
=
await
api
.
chats
.
get
(
jids
,
attrs
,
true
);
const
chat
=
await
api
.
chats
.
get
(
jids
,
attrs
,
true
);
if
(
chat
)
{
if
(
chat
)
{
return
chat
.
maybeShow
(
force
);
return
chat
.
maybeShow
(
force
);
...
@@ -1457,7 +1457,7 @@ converse.plugins.add('converse-chat', {
...
@@ -1457,7 +1457,7 @@ converse.plugins.add('converse-chat', {
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
const
chats
=
await
api
.
chatboxes
.
get
();
const
chats
=
await
api
.
chatboxes
.
get
();
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
PRIVATE_CHAT_TYPE
));
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
PRIVATE_CHAT_TYPE
));
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
_get
(
jids
);
return
_get
(
jids
);
}
}
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
...
...
src/headless/converse-chatboxes.js
View file @
6d975264
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
import
"
./converse-emoji
"
;
import
"
./converse-emoji
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
isString
}
from
"
lodash-es
"
;
import
log
from
"
./log
"
;
import
log
from
"
./log
"
;
const
{
Strophe
}
=
converse
.
env
;
const
{
Strophe
}
=
converse
.
env
;
...
@@ -153,7 +152,7 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -153,7 +152,7 @@ converse.plugins.add('converse-chatboxes', {
*/
*/
async
create
(
jids
=
[],
attrs
=
{},
model
)
{
async
create
(
jids
=
[],
attrs
=
{},
model
)
{
await
api
.
waitUntil
(
'
chatBoxesFetched
'
);
await
api
.
waitUntil
(
'
chatBoxesFetched
'
);
if
(
isString
(
jids
)
)
{
if
(
typeof
jids
===
'
string
'
)
{
return
createChatBox
(
jids
,
attrs
,
model
);
return
createChatBox
(
jids
,
attrs
,
model
);
}
else
{
}
else
{
return
Promise
.
all
(
jids
.
map
(
jid
=>
createChatBox
(
jid
,
attrs
,
model
)));
return
Promise
.
all
(
jids
.
map
(
jid
=>
createChatBox
(
jid
,
attrs
,
model
)));
...
@@ -168,7 +167,7 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -168,7 +167,7 @@ converse.plugins.add('converse-chatboxes', {
await
api
.
waitUntil
(
'
chatBoxesFetched
'
);
await
api
.
waitUntil
(
'
chatBoxesFetched
'
);
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
return
_converse
.
chatboxes
.
models
;
return
_converse
.
chatboxes
.
models
;
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
_converse
.
chatboxes
.
get
(
jids
.
toLowerCase
());
return
_converse
.
chatboxes
.
get
(
jids
.
toLowerCase
());
}
else
{
}
else
{
jids
=
jids
.
map
(
j
=>
j
.
toLowerCase
());
jids
=
jids
.
map
(
j
=>
j
.
toLowerCase
());
...
...
src/headless/converse-core.js
View file @
6d975264
...
@@ -20,7 +20,7 @@ import { Events } from '@converse/skeletor/src/events.js';
...
@@ -20,7 +20,7 @@ import { Events } from '@converse/skeletor/src/events.js';
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Router
}
from
'
@converse/skeletor/src/router.js
'
;
import
{
Router
}
from
'
@converse/skeletor/src/router.js
'
;
import
{
Strophe
,
$build
,
$iq
,
$msg
,
$pres
}
from
'
strophe.js/src/strophe
'
;
import
{
Strophe
,
$build
,
$iq
,
$msg
,
$pres
}
from
'
strophe.js/src/strophe
'
;
import
{
assignIn
,
debounce
,
invoke
,
isFunction
,
isObject
,
isString
,
pick
}
from
'
lodash-es
'
;
import
{
assignIn
,
debounce
,
invoke
,
isFunction
,
isObject
,
pick
}
from
'
lodash-es
'
;
import
{
html
}
from
'
lit-element
'
;
import
{
html
}
from
'
lit-element
'
;
import
{
sprintf
}
from
'
sprintf-js
'
;
import
{
sprintf
}
from
'
sprintf-js
'
;
...
@@ -712,7 +712,7 @@ export const api = _converse.api = {
...
@@ -712,7 +712,7 @@ export const api = _converse.api = {
if
(
isObject
(
key
))
{
if
(
isObject
(
key
))
{
assignIn
(
_converse
,
pick
(
key
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
,
pick
(
key
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
.
settings
,
pick
(
key
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
.
settings
,
pick
(
key
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
}
else
if
(
isString
(
'
string
'
)
)
{
}
else
if
(
typeof
key
===
'
string
'
)
{
o
[
key
]
=
val
;
o
[
key
]
=
val
;
assignIn
(
_converse
,
pick
(
o
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
,
pick
(
o
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
.
settings
,
pick
(
o
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
assignIn
(
_converse
.
settings
,
pick
(
o
,
Object
.
keys
(
DEFAULT_SETTINGS
)));
...
@@ -887,7 +887,7 @@ export const api = _converse.api = {
...
@@ -887,7 +887,7 @@ export const api = _converse.api = {
log
.
warn
(
Strophe
.
serialize
(
stanza
));
log
.
warn
(
Strophe
.
serialize
(
stanza
));
return
;
return
;
}
}
if
(
isString
(
stanza
)
)
{
if
(
typeof
stanza
===
'
string
'
)
{
stanza
=
u
.
toStanza
(
stanza
);
stanza
=
u
.
toStanza
(
stanza
);
}
}
if
(
stanza
.
tagName
===
'
iq
'
)
{
if
(
stanza
.
tagName
===
'
iq
'
)
{
...
...
src/headless/converse-disco.js
View file @
6d975264
...
@@ -9,7 +9,7 @@ import sizzle from "sizzle";
...
@@ -9,7 +9,7 @@ import sizzle from "sizzle";
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
is
Empty
,
is
Object
}
from
"
lodash-es
"
;
import
{
isObject
}
from
"
lodash-es
"
;
const
{
Strophe
,
$iq
,
utils
}
=
converse
.
env
;
const
{
Strophe
,
$iq
,
utils
}
=
converse
.
env
;
...
@@ -172,7 +172,7 @@ converse.plugins.add('converse-disco', {
...
@@ -172,7 +172,7 @@ converse.plugins.add('converse-disco', {
},
},
async
queryForItems
()
{
async
queryForItems
()
{
if
(
isEmpty
(
this
.
identities
.
where
({
'
category
'
:
'
server
'
}))
)
{
if
(
this
.
identities
.
where
({
'
category
'
:
'
server
'
}).
length
===
0
)
{
// Don't fetch features and items if this is not a
// Don't fetch features and items if this is not a
// server or a conference component.
// server or a conference component.
return
;
return
;
...
...
src/headless/converse-emoji.js
View file @
6d975264
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
import
{
ASCII_REPLACE_REGEX
,
CODEPOINTS_REGEX
}
from
'
./emoji_regexes.js
'
;
import
{
ASCII_REPLACE_REGEX
,
CODEPOINTS_REGEX
}
from
'
./emoji_regexes.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
find
,
isString
,
uniq
}
from
"
lodash-es
"
;
import
{
html
}
from
'
lit-html
'
;
import
{
html
}
from
'
lit-html
'
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -89,10 +88,13 @@ function convert (unicode) {
...
@@ -89,10 +88,13 @@ function convert (unicode) {
return
fromCodePoint
(
unicode
);
return
fromCodePoint
(
unicode
);
}
}
function
unique
(
arr
)
{
return
[...
new
Set
(
arr
)];
}
function
getTonedEmojis
()
{
function
getTonedEmojis
()
{
if
(
!
converse
.
emojis
.
toned
)
{
if
(
!
converse
.
emojis
.
toned
)
{
converse
.
emojis
.
toned
=
uniq
(
converse
.
emojis
.
toned
=
uniq
ue
(
Object
.
values
(
converse
.
emojis
.
json
.
people
)
Object
.
values
(
converse
.
emojis
.
json
.
people
)
.
filter
(
person
=>
person
.
sn
.
includes
(
'
_tone
'
))
.
filter
(
person
=>
person
.
sn
.
includes
(
'
_tone
'
))
.
map
(
person
=>
person
.
sn
.
replace
(
/_tone
[
1-5
]
/
,
''
))
.
map
(
person
=>
person
.
sn
.
replace
(
/_tone
[
1-5
]
/
,
''
))
...
@@ -198,7 +200,7 @@ function addEmojisMarkup (text, options) {
...
@@ -198,7 +200,7 @@ function addEmojisMarkup (text, options) {
.
forEach
(
ref
=>
{
.
forEach
(
ref
=>
{
const
text
=
list
.
shift
();
const
text
=
list
.
shift
();
const
emoji
=
getEmojiMarkup
(
ref
,
options
);
const
emoji
=
getEmojiMarkup
(
ref
,
options
);
if
(
isString
(
emoji
)
)
{
if
(
typeof
emoji
===
'
string
'
)
{
list
=
[
text
.
slice
(
0
,
ref
.
begin
)
+
emoji
+
text
.
slice
(
ref
.
end
),
...
list
];
list
=
[
text
.
slice
(
0
,
ref
.
begin
)
+
emoji
+
text
.
slice
(
ref
.
end
),
...
list
];
}
else
{
}
else
{
list
=
[
text
.
slice
(
0
,
ref
.
begin
),
emoji
,
text
.
slice
(
ref
.
end
),
...
list
];
list
=
[
text
.
slice
(
0
,
ref
.
begin
),
emoji
,
text
.
slice
(
ref
.
end
),
...
list
];
...
@@ -349,7 +351,7 @@ converse.plugins.add('converse-emoji', {
...
@@ -349,7 +351,7 @@ converse.plugins.add('converse-emoji', {
.
filter
((
c
,
i
,
arr
)
=>
arr
.
indexOf
(
c
)
==
i
);
.
filter
((
c
,
i
,
arr
)
=>
arr
.
indexOf
(
c
)
==
i
);
emojis_by_attribute
[
attr
]
=
{};
emojis_by_attribute
[
attr
]
=
{};
all_variants
.
forEach
(
v
=>
(
emojis_by_attribute
[
attr
][
v
]
=
find
(
converse
.
emojis
.
list
,
i
=>
(
i
[
attr
]
===
v
)
)));
all_variants
.
forEach
(
v
=>
(
emojis_by_attribute
[
attr
][
v
]
=
converse
.
emojis
.
list
.
find
(
i
=>
i
[
attr
]
===
v
)));
return
emojis_by_attribute
[
attr
];
return
emojis_by_attribute
[
attr
];
}
}
});
});
...
...
src/headless/converse-headlines.js
View file @
6d975264
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
* @copyright 2020, the Converse.js contributors
* @copyright 2020, the Converse.js contributors
* @description XEP-0045 Multi-User Chat Views
* @description XEP-0045 Multi-User Chat Views
*/
*/
import
{
isString
}
from
"
lodash-es
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
st
from
"
./utils/stanza
"
;
import
st
from
"
./utils/stanza
"
;
...
@@ -148,7 +147,7 @@ converse.plugins.add('converse-headlines', {
...
@@ -148,7 +147,7 @@ converse.plugins.add('converse-headlines', {
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
const
chats
=
await
api
.
chatboxes
.
get
();
const
chats
=
await
api
.
chatboxes
.
get
();
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
HEADLINES_TYPE
));
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
HEADLINES_TYPE
));
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
_get
(
jids
);
return
_get
(
jids
);
}
}
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
...
...
src/headless/converse-muc.js
View file @
6d975264
...
@@ -9,7 +9,7 @@ import "./converse-disco";
...
@@ -9,7 +9,7 @@ import "./converse-disco";
import
"
./converse-emoji
"
;
import
"
./converse-emoji
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
clone
,
debounce
,
intersection
,
invoke
,
isElement
,
isObject
,
isString
,
pick
,
uniq
,
zipObject
}
from
"
lodash-es
"
;
import
{
debounce
,
intersection
,
invoke
,
isElement
,
isObject
,
pick
,
zipObject
}
from
"
lodash-es
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
log
from
"
./log
"
;
import
log
from
"
./log
"
;
import
muc_utils
from
"
./utils/muc
"
;
import
muc_utils
from
"
./utils/muc
"
;
...
@@ -135,7 +135,7 @@ converse.plugins.add('converse-muc', {
...
@@ -135,7 +135,7 @@ converse.plugins.add('converse-muc', {
});
});
api
.
promises
.
add
([
'
roomsAutoJoined
'
]);
api
.
promises
.
add
([
'
roomsAutoJoined
'
]);
if
(
api
.
settings
.
get
(
'
locked_muc_domain
'
)
&&
!
isString
(
api
.
settings
.
get
(
'
muc_domain
'
)
))
{
if
(
api
.
settings
.
get
(
'
locked_muc_domain
'
)
&&
(
typeof
api
.
settings
.
get
(
'
muc_domain
'
)
!==
'
string
'
))
{
throw
new
Error
(
"
Config Error: it makes no sense to set locked_muc_domain
"
+
throw
new
Error
(
"
Config Error: it makes no sense to set locked_muc_domain
"
+
"
to true when muc_domain is not set
"
);
"
to true when muc_domain is not set
"
);
}
}
...
@@ -1372,7 +1372,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1372,7 +1372,7 @@ converse.plugins.add('converse-muc', {
* @returns { Promise }
* @returns { Promise }
*/
*/
setAffiliations
(
members
)
{
setAffiliations
(
members
)
{
const
affiliations
=
uniq
(
members
.
map
(
m
=>
m
.
affiliation
))
;
const
affiliations
=
[...
new
Set
(
members
.
map
(
m
=>
m
.
affiliation
))]
;
return
Promise
.
all
(
affiliations
.
map
(
a
=>
this
.
setAffiliation
(
a
,
members
)));
return
Promise
.
all
(
affiliations
.
map
(
a
=>
this
.
setAffiliation
(
a
,
members
)));
},
},
...
@@ -1713,7 +1713,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1713,7 +1713,7 @@ converse.plugins.add('converse-muc', {
* message, as returned by {@link st.parseMUCMessage}
* message, as returned by {@link st.parseMUCMessage}
*/
*/
async
handleSubjectChange
(
attrs
)
{
async
handleSubjectChange
(
attrs
)
{
if
(
isString
(
attrs
.
subject
)
&&
!
attrs
.
thread
&&
!
attrs
.
message
)
{
if
(
typeof
attrs
.
subject
===
'
string
'
&&
!
attrs
.
thread
&&
!
attrs
.
message
)
{
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// -----------------------------------------------------
// -----------------------------------------------------
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
...
@@ -2697,13 +2697,13 @@ converse.plugins.add('converse-muc', {
...
@@ -2697,13 +2697,13 @@ converse.plugins.add('converse-muc', {
*/
*/
async
function
autoJoinRooms
()
{
async
function
autoJoinRooms
()
{
await
Promise
.
all
(
api
.
settings
.
get
(
'
auto_join_rooms
'
).
map
(
muc
=>
{
await
Promise
.
all
(
api
.
settings
.
get
(
'
auto_join_rooms
'
).
map
(
muc
=>
{
if
(
isString
(
muc
)
)
{
if
(
typeof
muc
===
'
string
'
)
{
if
(
_converse
.
chatboxes
.
where
({
'
jid
'
:
muc
}).
length
)
{
if
(
_converse
.
chatboxes
.
where
({
'
jid
'
:
muc
}).
length
)
{
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
return
api
.
rooms
.
open
(
muc
);
return
api
.
rooms
.
open
(
muc
);
}
else
if
(
isObject
(
muc
))
{
}
else
if
(
isObject
(
muc
))
{
return
api
.
rooms
.
open
(
muc
.
jid
,
clone
(
muc
)
);
return
api
.
rooms
.
open
(
muc
.
jid
,
{...
muc
}
);
}
else
{
}
else
{
log
.
error
(
'
Invalid muc criteria specified for "auto_join_rooms"
'
);
log
.
error
(
'
Invalid muc criteria specified for "auto_join_rooms"
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -2816,13 +2816,13 @@ converse.plugins.add('converse-muc', {
...
@@ -2816,13 +2816,13 @@ converse.plugins.add('converse-muc', {
* @returns {Promise} Promise which resolves with the Model representing the chat.
* @returns {Promise} Promise which resolves with the Model representing the chat.
*/
*/
create
(
jids
,
attrs
=
{})
{
create
(
jids
,
attrs
=
{})
{
attrs
=
isString
(
attrs
)
?
{
'
nick
'
:
attrs
}
:
(
attrs
||
{});
attrs
=
typeof
attrs
===
'
string
'
?
{
'
nick
'
:
attrs
}
:
(
attrs
||
{});
if
(
!
attrs
.
nick
&&
api
.
settings
.
get
(
'
muc_nickname_from_jid
'
))
{
if
(
!
attrs
.
nick
&&
api
.
settings
.
get
(
'
muc_nickname_from_jid
'
))
{
attrs
.
nick
=
Strophe
.
getNodeFromJid
(
_converse
.
bare_jid
);
attrs
.
nick
=
Strophe
.
getNodeFromJid
(
_converse
.
bare_jid
);
}
}
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
throw
new
TypeError
(
'
rooms.create: You need to provide at least one JID
'
);
throw
new
TypeError
(
'
rooms.create: You need to provide at least one JID
'
);
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
createChatRoom
(
jids
,
attrs
);
return
createChatRoom
(
jids
,
attrs
);
}
}
return
jids
.
map
(
jid
=>
createChatRoom
(
jid
,
attrs
));
return
jids
.
map
(
jid
=>
createChatRoom
(
jid
,
attrs
));
...
@@ -2893,7 +2893,7 @@ converse.plugins.add('converse-muc', {
...
@@ -2893,7 +2893,7 @@ converse.plugins.add('converse-muc', {
const
err_msg
=
'
rooms.open: You need to provide at least one JID
'
;
const
err_msg
=
'
rooms.open: You need to provide at least one JID
'
;
log
.
error
(
err_msg
);
log
.
error
(
err_msg
);
throw
(
new
TypeError
(
err_msg
));
throw
(
new
TypeError
(
err_msg
));
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
const
room
=
await
api
.
rooms
.
create
(
jids
,
attrs
);
const
room
=
await
api
.
rooms
.
create
(
jids
,
attrs
);
room
&&
room
.
maybeShow
(
force
);
room
&&
room
.
maybeShow
(
force
);
return
room
;
return
room
;
...
@@ -2944,7 +2944,7 @@ converse.plugins.add('converse-muc', {
...
@@ -2944,7 +2944,7 @@ converse.plugins.add('converse-muc', {
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
const
chats
=
await
api
.
chatboxes
.
get
();
const
chats
=
await
api
.
chatboxes
.
get
();
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
));
return
chats
.
filter
(
c
=>
(
c
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
));
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
_get
(
jids
);
return
_get
(
jids
);
}
}
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
return
Promise
.
all
(
jids
.
map
(
jid
=>
_get
(
jid
)));
...
...
src/headless/converse-roster.js
View file @
6d975264
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
import
"
@converse/headless/converse-status
"
;
import
"
@converse/headless/converse-status
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
invoke
,
is
Empty
,
isNaN
,
isString
,
propertyOf
,
sum
}
from
"
lodash-es
"
;
import
{
invoke
,
is
NaN
,
propertyOf
,
sum
}
from
"
lodash-es
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
log
from
"
./log
"
;
import
log
from
"
./log
"
;
...
@@ -514,7 +514,7 @@ converse.plugins.add('converse-roster', {
...
@@ -514,7 +514,7 @@ converse.plugins.add('converse-roster', {
* @param { Function } errback - A function to call if an error occurred
* @param { Function } errback - A function to call if an error occurred
*/
*/
sendContactAddIQ
(
jid
,
name
,
groups
)
{
sendContactAddIQ
(
jid
,
name
,
groups
)
{
name
=
isEmpty
(
name
)
?
null
:
name
;
name
=
name
?
name
:
null
;
const
iq
=
$iq
({
'
type
'
:
'
set
'
})
const
iq
=
$iq
({
'
type
'
:
'
set
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
ROSTER
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
ROSTER
})
.
c
(
'
item
'
,
{
jid
,
name
});
.
c
(
'
item
'
,
{
jid
,
name
});
...
@@ -1075,7 +1075,7 @@ converse.plugins.add('converse-roster', {
...
@@ -1075,7 +1075,7 @@ converse.plugins.add('converse-roster', {
const
_getter
=
jid
=>
_converse
.
roster
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
const
_getter
=
jid
=>
_converse
.
roster
.
get
(
Strophe
.
getBareJidFromJid
(
jid
));
if
(
jids
===
undefined
)
{
if
(
jids
===
undefined
)
{
jids
=
_converse
.
roster
.
pluck
(
'
jid
'
);
jids
=
_converse
.
roster
.
pluck
(
'
jid
'
);
}
else
if
(
isString
(
jids
)
)
{
}
else
if
(
typeof
jids
===
'
string
'
)
{
return
_getter
(
jids
);
return
_getter
(
jids
);
}
}
return
jids
.
map
(
_getter
);
return
jids
.
map
(
_getter
);
...
@@ -1086,8 +1086,7 @@ converse.plugins.add('converse-roster', {
...
@@ -1086,8 +1086,7 @@ converse.plugins.add('converse-roster', {
*
*
* @method _converse.api.contacts.add
* @method _converse.api.contacts.add
* @param {string} jid The JID of the contact to be added
* @param {string} jid The JID of the contact to be added
* @param {string} [name] A custom name to show the user by
* @param {string} [name] A custom name to show the user by in the roster
* in the roster.
* @example
* @example
* _converse.api.contacts.add('buddy@example.com')
* _converse.api.contacts.add('buddy@example.com')
* @example
* @example
...
@@ -1095,10 +1094,10 @@ converse.plugins.add('converse-roster', {
...
@@ -1095,10 +1094,10 @@ converse.plugins.add('converse-roster', {
*/
*/
async
add
(
jid
,
name
)
{
async
add
(
jid
,
name
)
{
await
api
.
waitUntil
(
'
rosterContactsFetched
'
);
await
api
.
waitUntil
(
'
rosterContactsFetched
'
);
if
(
!
isString
(
jid
)
||
!
jid
.
includes
(
'
@
'
))
{
if
(
typeof
jid
!==
'
string
'
||
!
jid
.
includes
(
'
@
'
))
{
throw
new
TypeError
(
'
contacts.add: invalid jid
'
);
throw
new
TypeError
(
'
contacts.add: invalid jid
'
);
}
}
return
_converse
.
roster
.
addAndSubscribe
(
jid
,
isEmpty
(
name
)?
jid
:
name
);
return
_converse
.
roster
.
addAndSubscribe
(
jid
,
name
);
}
}
}
}
});
});
...
...
src/headless/converse-status.js
View file @
6d975264
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* @copyright The Converse.js contributors
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @license Mozilla Public License (MPLv2)
*/
*/
import
{
isNaN
,
isObject
,
isString
}
from
"
lodash-es
"
;
import
{
isNaN
,
isObject
}
from
"
lodash-es
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
...
@@ -49,8 +49,8 @@ converse.plugins.add('converse-status', {
...
@@ -49,8 +49,8 @@ converse.plugins.add('converse-status', {
},
},
constructPresence
(
type
,
to
=
null
,
status_message
)
{
constructPresence
(
type
,
to
=
null
,
status_message
)
{
type
=
isString
(
type
)
?
type
:
(
this
.
get
(
'
status
'
)
||
api
.
settings
.
get
(
"
default_state
"
));
type
=
typeof
type
===
'
string
'
?
type
:
(
this
.
get
(
'
status
'
)
||
api
.
settings
.
get
(
"
default_state
"
));
status_message
=
isString
(
status_message
)
?
status_message
:
this
.
get
(
'
status_message
'
);
status_message
=
typeof
status_message
===
'
string
'
?
status_message
:
this
.
get
(
'
status_message
'
);
let
presence
;
let
presence
;
const
attrs
=
{
to
};
const
attrs
=
{
to
};
if
((
type
===
'
unavailable
'
)
||
if
((
type
===
'
unavailable
'
)
||
...
@@ -293,7 +293,7 @@ converse.plugins.add('converse-status', {
...
@@ -293,7 +293,7 @@ converse.plugins.add('converse-status', {
'
Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1
'
'
Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1
'
);
);
}
}
if
(
isString
(
message
)
)
{
if
(
typeof
message
===
'
string
'
)
{
data
.
status_message
=
message
;
data
.
status_message
=
message
;
}
}
await
api
.
waitUntil
(
'
statusInitialized
'
);
await
api
.
waitUntil
(
'
statusInitialized
'
);
...
...
src/headless/converse-vcard.js
View file @
6d975264
...
@@ -8,7 +8,6 @@ import log from "@converse/headless/log";
...
@@ -8,7 +8,6 @@ import log from "@converse/headless/log";
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Collection
}
from
"
@converse/skeletor/src/collection
"
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
./converse-core
"
;
import
{
has
,
isString
}
from
"
lodash-es
"
;
const
{
Strophe
,
$iq
,
dayjs
}
=
converse
.
env
;
const
{
Strophe
,
$iq
,
dayjs
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -30,7 +29,7 @@ converse.plugins.add('converse-vcard', {
...
@@ -30,7 +29,7 @@ converse.plugins.add('converse-vcard', {
}
}
},
},
getFullname
(){
getFullname
()
{
const
{
_converse
}
=
this
.
__super__
;
const
{
_converse
}
=
this
.
__super__
;
const
fullname
=
this
.
__super__
.
getFullname
.
apply
(
this
);
const
fullname
=
this
.
__super__
.
getFullname
.
apply
(
this
);
if
(
!
fullname
&&
_converse
.
xmppstatus
.
vcard
)
{
if
(
!
fullname
&&
_converse
.
xmppstatus
.
vcard
)
{
...
@@ -88,7 +87,7 @@ converse.plugins.add('converse-vcard', {
...
@@ -88,7 +87,7 @@ converse.plugins.add('converse-vcard', {
}
else
{
}
else
{
(
attrs
=
{})[
key
]
=
val
;
(
attrs
=
{})[
key
]
=
val
;
}
}
if
(
has
(
attrs
,
'
image
'
)
&&
!
attrs
[
'
image
'
])
{
if
(
'
image
'
in
attrs
&&
!
attrs
[
'
image
'
])
{
attrs
[
'
image
'
]
=
_converse
.
DEFAULT_IMAGE
;
attrs
[
'
image
'
]
=
_converse
.
DEFAULT_IMAGE
;
attrs
[
'
image_type
'
]
=
_converse
.
DEFAULT_IMAGE_TYPE
;
attrs
[
'
image_type
'
]
=
_converse
.
DEFAULT_IMAGE_TYPE
;
return
Model
.
prototype
.
set
.
call
(
this
,
attrs
,
options
);
return
Model
.
prototype
.
set
.
call
(
this
,
attrs
,
options
);
...
@@ -337,7 +336,7 @@ converse.plugins.add('converse-vcard', {
...
@@ -337,7 +336,7 @@ converse.plugins.add('converse-vcard', {
* });
* });
*/
*/
get
(
model
,
force
)
{
get
(
model
,
force
)
{
if
(
isString
(
model
)
)
{
if
(
typeof
model
===
'
string
'
)
{
return
getVCard
(
_converse
,
model
);
return
getVCard
(
_converse
,
model
);
}
else
if
(
force
||
}
else
if
(
force
||
!
model
.
get
(
'
vcard_updated
'
)
||
!
model
.
get
(
'
vcard_updated
'
)
||
...
@@ -371,7 +370,7 @@ converse.plugins.add('converse-vcard', {
...
@@ -371,7 +370,7 @@ converse.plugins.add('converse-vcard', {
*/
*/
async
update
(
model
,
force
)
{
async
update
(
model
,
force
)
{
const
data
=
await
this
.
get
(
model
,
force
);
const
data
=
await
this
.
get
(
model
,
force
);
model
=
isString
(
model
)
?
_converse
.
vcards
.
findWhere
({
'
jid
'
:
model
})
:
model
;
model
=
typeof
model
===
'
string
'
?
_converse
.
vcards
.
findWhere
({
'
jid
'
:
model
})
:
model
;
if
(
!
model
)
{
if
(
!
model
)
{
log
.
error
(
`Could not find a VCard model for
${
model
}
`
);
log
.
error
(
`Could not find a VCard model for
${
model
}
`
);
return
;
return
;
...
...
src/headless/utils/core.js
View file @
6d975264
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
*/
*/
import
*
as
strophe
from
'
strophe.js/src/core
'
;
import
*
as
strophe
from
'
strophe.js/src/core
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
Model
}
from
'
@converse/skeletor/src/model.js
'
;
import
{
compact
,
last
,
isElement
,
isObject
,
isString
}
from
"
lodash-es
"
;
import
{
compact
,
last
,
isElement
,
isObject
}
from
"
lodash-es
"
;
import
log
from
"
@converse/headless/log
"
;
import
log
from
"
@converse/headless/log
"
;
import
sizzle
from
"
sizzle
"
;
import
sizzle
from
"
sizzle
"
;
...
@@ -71,7 +71,7 @@ u.prefixMentions = function (message) {
...
@@ -71,7 +71,7 @@ u.prefixMentions = function (message) {
};
};
u
.
isValidJID
=
function
(
jid
)
{
u
.
isValidJID
=
function
(
jid
)
{
if
(
isString
(
jid
)
)
{
if
(
typeof
jid
===
'
string
'
)
{
return
compact
(
jid
.
split
(
'
@
'
)).
length
===
2
&&
!
jid
.
startsWith
(
'
@
'
)
&&
!
jid
.
endsWith
(
'
@
'
);
return
compact
(
jid
.
split
(
'
@
'
)).
length
===
2
&&
!
jid
.
startsWith
(
'
@
'
)
&&
!
jid
.
endsWith
(
'
@
'
);
}
}
return
false
;
return
false
;
...
@@ -82,7 +82,7 @@ u.isValidMUCJID = function (jid) {
...
@@ -82,7 +82,7 @@ u.isValidMUCJID = function (jid) {
};
};
u
.
isSameBareJID
=
function
(
jid1
,
jid2
)
{
u
.
isSameBareJID
=
function
(
jid1
,
jid2
)
{
if
(
!
isString
(
jid1
)
||
!
isString
(
jid2
)
)
{
if
(
typeof
jid1
!==
'
string
'
||
typeof
jid2
!==
'
string
'
)
{
return
false
;
return
false
;
}
}
return
Strophe
.
getBareJidFromJid
(
jid1
).
toLowerCase
()
===
return
Strophe
.
getBareJidFromJid
(
jid1
).
toLowerCase
()
===
...
@@ -91,7 +91,7 @@ u.isSameBareJID = function (jid1, jid2) {
...
@@ -91,7 +91,7 @@ u.isSameBareJID = function (jid1, jid2) {
u
.
isSameDomain
=
function
(
jid1
,
jid2
)
{
u
.
isSameDomain
=
function
(
jid1
,
jid2
)
{
if
(
!
isString
(
jid1
)
||
!
isString
(
jid2
)
)
{
if
(
typeof
jid1
!==
'
string
'
||
typeof
jid2
!==
'
string
'
)
{
return
false
;
return
false
;
}
}
return
Strophe
.
getDomainFromJid
(
jid1
).
toLowerCase
()
===
return
Strophe
.
getDomainFromJid
(
jid1
).
toLowerCase
()
===
...
...
src/templates/directives/body.js
View file @
6d975264
...
@@ -3,7 +3,6 @@ import log from '@converse/headless/log';
...
@@ -3,7 +3,6 @@ import log from '@converse/headless/log';
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
convertASCII2Emoji
,
getEmojiMarkup
,
getCodePointReferences
,
getShortnameReferences
}
from
"
@converse/headless/converse-emoji.js
"
;
import
{
convertASCII2Emoji
,
getEmojiMarkup
,
getCodePointReferences
,
getShortnameReferences
}
from
"
@converse/headless/converse-emoji.js
"
;
import
{
directive
,
html
}
from
"
lit-html
"
;
import
{
directive
,
html
}
from
"
lit-html
"
;
import
{
isString
}
from
"
lodash-es
"
;
import
{
until
}
from
'
lit-html/directives/until.js
'
;
import
{
until
}
from
'
lit-html/directives/until.js
'
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -84,6 +83,7 @@ class MessageText extends String {
...
@@ -84,6 +83,7 @@ class MessageText extends String {
// Subtract `/me ` from 3rd person messages
// Subtract `/me ` from 3rd person messages
if
(
this
.
isMeCommand
())
list
[
0
]
=
list
[
0
].
substring
(
4
);
if
(
this
.
isMeCommand
())
list
[
0
]
=
list
[
0
].
substring
(
4
);
const
isString
=
(
s
)
=>
typeof
s
===
'
string
'
;
return
list
.
reduce
((
acc
,
i
)
=>
isString
(
i
)
?
[...
acc
,
MessageText
.
replaceText
(
i
)]
:
[...
acc
,
i
],
[]);
return
list
.
reduce
((
acc
,
i
)
=>
isString
(
i
)
?
[...
acc
,
MessageText
.
replaceText
(
i
)]
:
[...
acc
,
i
],
[]);
}
}
}
}
...
...
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