Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send and handle leave messages for XMPP MUC #246

Merged
merged 4 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/coms.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class ComsService extends Service {
leaveChannel (channel) {
switch (channel.protocol) {
case 'XMPP':
// TODO implement
this.xmpp.leave(channel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually remove the protocol switch now, and do something like this:

    this.getServiceForSockethubPlatform(channel.protocol)
        .leave(channel);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍

break;
case 'IRC':
this.irc.leave(channel);
Expand Down
8 changes: 0 additions & 8 deletions app/services/sockethub-irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,6 @@ export default class SockethubIrcService extends Service {
*/
leave (channel) {
if (!channel.isUserChannel) {
// TODO Do we really need to create this room for leaving? It should
// already have been created when joining.
this.sockethub.ActivityStreams.Object.create({
'@type': "room",
'@id': channel.sockethubChannelId,
displayName: channel.name
});

let leaveMsg = buildActivityObject(channel.account, {
'@type': 'leave',
target: channel.sockethubChannelId,
Expand Down
13 changes: 13 additions & 0 deletions app/services/sockethub-xmpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ export default class SockethubXmppService extends Service {
channel.addMessage(channelMessage);
}

leave (channel) {
if (!channel.isUserChannel) {
const leaveMsg = buildActivityObject(channel.account, {
'@type': 'leave',
target: channel.sockethubChannelId,
object: {}
});

this.log('leave', 'leaving channel', leaveMsg);
this.sockethub.socket.emit('message', leaveMsg);
}
}

/**
* Ask for a channel's attendance list (users currently joined)
*
Expand Down