Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
solid-xmpp-chat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Components
solid-xmpp-chat
Commits
3b39125a
Commit
3b39125a
authored
4 years ago
by
ubermanu
Browse files
Options
Downloads
Patches
Plain Diff
format code
parent
f3d543b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/converse-rai.js
+18
-17
18 additions, 17 deletions
src/plugins/converse-rai.js
with
18 additions
and
17 deletions
src/plugins/converse-rai.js
+
18
−
17
View file @
3b39125a
...
@@ -19,7 +19,7 @@ converse.plugins.add('converse-rai', {
...
@@ -19,7 +19,7 @@ converse.plugins.add('converse-rai', {
* @method _converse.ChatRoom#onConnectionStatusChanged
* @method _converse.ChatRoom#onConnectionStatusChanged
*/
*/
async
onConnectionStatusChanged
()
{
async
onConnectionStatusChanged
()
{
console
.
log
(
'
ChatRoom#onConnectionStatusChanged
'
)
console
.
log
(
'
ChatRoom#onConnectionStatusChanged
'
)
;
const
{
api
}
=
this
.
__super__
.
_converse
;
const
{
api
}
=
this
.
__super__
.
_converse
;
if
(
this
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
)
{
if
(
this
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
)
{
if
(
this
.
get
(
'
hidden
'
)
&&
api
.
settings
.
get
(
'
muc_subscribe_to_rai
'
)
&&
this
.
getOwnAffiliation
()
!==
'
none
'
)
{
if
(
this
.
get
(
'
hidden
'
)
&&
api
.
settings
.
get
(
'
muc_subscribe_to_rai
'
)
&&
this
.
getOwnAffiliation
()
!==
'
none
'
)
{
...
@@ -37,7 +37,7 @@ converse.plugins.add('converse-rai', {
...
@@ -37,7 +37,7 @@ converse.plugins.add('converse-rai', {
* @method _converse.ChatRoom#onHiddenChange
* @method _converse.ChatRoom#onHiddenChange
*/
*/
async
onHiddenChange
()
{
async
onHiddenChange
()
{
console
.
log
(
'
ChatRoomView#onHiddenChange
'
)
console
.
log
(
'
ChatRoomView#onHiddenChange
'
)
;
const
conn_status
=
this
.
session
.
get
(
'
connection_status
'
);
const
conn_status
=
this
.
session
.
get
(
'
connection_status
'
);
const
{
api
}
=
this
.
__super__
.
_converse
;
const
{
api
}
=
this
.
__super__
.
_converse
;
...
@@ -65,7 +65,7 @@ converse.plugins.add('converse-rai', {
...
@@ -65,7 +65,7 @@ converse.plugins.add('converse-rai', {
* @method _converse.ChatRoom#enableRAI
* @method _converse.ChatRoom#enableRAI
*/
*/
enableRAI
()
{
enableRAI
()
{
console
.
log
(
'
ChatRoom#enableRAI
'
)
console
.
log
(
'
ChatRoom#enableRAI
'
)
;
const
{
api
}
=
this
.
__super__
.
_converse
;
const
{
api
}
=
this
.
__super__
.
_converse
;
if
(
api
.
settings
.
get
(
'
muc_subscribe_to_rai
'
))
{
if
(
api
.
settings
.
get
(
'
muc_subscribe_to_rai
'
))
{
api
.
rooms
.
subscribe
(
this
.
get
(
'
jid
'
));
api
.
rooms
.
subscribe
(
this
.
get
(
'
jid
'
));
...
@@ -85,25 +85,26 @@ converse.plugins.add('converse-rai', {
...
@@ -85,25 +85,26 @@ converse.plugins.add('converse-rai', {
const
msg
=
msgs
.
find
(
m
=>
m
.
get
(
'
sender
'
)
===
'
them
'
&&
(
force
||
m
.
get
(
'
is_markable
'
)));
const
msg
=
msgs
.
find
(
m
=>
m
.
get
(
'
sender
'
)
===
'
them
'
&&
(
force
||
m
.
get
(
'
is_markable
'
)));
msg
&&
this
.
sendMarkerForMessage
(
msg
,
type
,
force
);
msg
&&
this
.
sendMarkerForMessage
(
msg
,
type
,
force
);
},
},
}
}
,
},
},
initialize
()
{
initialize
()
{
const
{
Strophe
,
_
,
$pres
,
u
}
=
converse
.
env
;
const
{
Strophe
,
_
,
$pres
,
u
}
=
converse
.
env
;
const
_converse
=
this
.
_converse
;
const
_converse
=
this
.
_converse
;
const
{
api
}
=
_converse
;
// Register namespace
// Register namespace
Strophe
.
addNamespace
(
'
RAI
'
,
'
urn:xmpp:rai:0
'
);
Strophe
.
addNamespace
(
'
RAI
'
,
'
urn:xmpp:rai:0
'
);
_converse
.
api
.
listen
.
on
(
'
addClientFeatures
'
,
()
=>
{
api
.
listen
.
on
(
'
addClientFeatures
'
,
()
=>
{
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
RAI
);
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
RAI
);
});
});
// Register settings
// Register settings
_converse
.
api
.
settings
.
extend
({
api
.
settings
.
extend
({
muc_subscribe_to_rai
:
true
,
muc_subscribe_to_rai
:
true
,
});
});
Object
.
assign
(
_converse
.
api
.
rooms
,
{
Object
.
assign
(
api
.
rooms
,
{
/**
/**
* Send an RAI stanza for the given jids.
* Send an RAI stanza for the given jids.
* The presence stanza is sent for a whole muc domain.
* The presence stanza is sent for a whole muc domain.
...
@@ -120,18 +121,18 @@ converse.plugins.add('converse-rai', {
...
@@ -120,18 +121,18 @@ converse.plugins.add('converse-rai', {
_
.
uniq
(
muc_domains
).
forEach
(
muc_domain
=>
{
_
.
uniq
(
muc_domains
).
forEach
(
muc_domain
=>
{
const
rai
=
$pres
({
to
:
muc_domain
,
id
:
u
.
getUniqueId
()
}).
c
(
'
rai
'
,
{
const
rai
=
$pres
({
to
:
muc_domain
,
id
:
u
.
getUniqueId
()
}).
c
(
'
rai
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
RAI
'
xmlns
'
:
Strophe
.
NS
.
RAI
,
});
});
_converse
.
api
.
send
(
rai
);
api
.
send
(
rai
);
console
.
log
(
'
Sent RAI stanza for muc_domain
'
,
muc_domain
,
rai
.
toString
());
console
.
log
(
'
Sent RAI stanza for muc_domain
'
,
muc_domain
,
rai
.
toString
());
});
});
}
}
,
});
});
function
mucActivityHandler
(
message
)
{
function
mucActivityHandler
(
message
)
{
console
.
log
(
'
mucActivityHandler
'
,
message
)
console
.
log
(
'
mucActivityHandler
'
,
message
)
;
const
from_jid
=
message
.
attributes
.
from
?.
nodevalue
const
from_jid
=
message
.
attributes
.
from
?.
nodevalue
;
const
room_jid
=
from_jid
?.
split
(
"
/
"
)[
0
]
const
room_jid
=
from_jid
?.
split
(
'
/
'
)[
0
]
;
let
room
=
''
;
let
room
=
''
;
let
ignore
=
false
;
let
ignore
=
false
;
...
@@ -153,7 +154,7 @@ converse.plugins.add('converse-rai', {
...
@@ -153,7 +154,7 @@ converse.plugins.add('converse-rai', {
if
(
activity
&&
activity
.
namespaceURI
===
Strophe
.
NS
.
RAI
)
{
if
(
activity
&&
activity
.
namespaceURI
===
Strophe
.
NS
.
RAI
)
{
const
jid
=
activity
.
textContent
;
const
jid
=
activity
.
textContent
;
// TODO: Give the chatroom object instead of the jid
// TODO: Give the chatroom object instead of the jid
_converse
.
api
.
trigger
(
'
chatRoomHasActivity
'
,
jid
);
api
.
trigger
(
'
chatRoomHasActivity
'
,
jid
);
}
}
});
});
}
}
...
@@ -162,11 +163,11 @@ converse.plugins.add('converse-rai', {
...
@@ -162,11 +163,11 @@ converse.plugins.add('converse-rai', {
}
}
// TODO: On loading subscribe to all the ChatViews in navigation (into another plugin)
// TODO: On loading subscribe to all the ChatViews in navigation (into another plugin)
_converse
.
api
.
listen
.
on
(
'
connected
'
,
()
=>
{
api
.
listen
.
on
(
'
connected
'
,
()
=>
{
_converse
.
connection
.
addHandler
(
mucActivityHandler
,
null
,
'
message
'
,
'
groupchat
'
);
_converse
.
connection
.
addHandler
(
mucActivityHandler
,
null
,
'
message
'
,
'
groupchat
'
);
});
});
// TODO: Remove
// TODO: Remove
//
_converse.
api.listen.on('send', stanza => console.log('send', stanza));
// api.listen.on('send', stanza => console.log('send', stanza));
}
}
,
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment