Skip to content

Commit

Permalink
Merge pull request #276 from 67P/sockethub/observe_to_query
Browse files Browse the repository at this point in the history
Replace Sockethub type "observe" with "query"
  • Loading branch information
raucao committed Feb 8, 2022
2 parents 33515f8 + eee5430 commit a308579
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions app/services/coms.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ export default class ComsService extends Service {
this.log(`${message.context}_message`, 'SH message', message);

switch (message.type) {
case 'query':
if (message.object['type'] === 'attendance') {
this.updateChannelUserList(message);
}
break;
// TODO remove deprecated term in favor of query
case 'observe':
if (message.object['type'] === 'attendance') {
this.updateChannelUserList(message);
Expand Down
12 changes: 6 additions & 6 deletions app/services/sockethub-irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class SockethubIrcService extends Service {
handleJoinCompleted (message) {
const channel = this.coms.channels.findBy('sockethubChannelId', message.target.id);
if (channel) {
this.observeChannel(channel);
this.queryAttendance(channel);
}
}

Expand Down Expand Up @@ -239,17 +239,17 @@ export default class SockethubIrcService extends Service {
* Ask for a channel's attendance list (users currently joined)
* @public
*/
observeChannel (channel) {
let observeMsg = buildActivityObject(channel.account, {
type: 'observe',
queryAttendance (channel) {
let msg = buildActivityObject(channel.account, {
type: 'query',
target: channel.sockethubChannelId,
object: {
type: 'attendance'
}
});

this.log('irc', 'asking for attendance list', observeMsg);
this.sockethub.socket.emit('message', observeMsg);
this.log('irc', 'asking for attendance list', msg);
this.sockethub.socket.emit('message', msg);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions app/services/sockethub-xmpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class SockethubXmppService extends Service {
const channelId = message.target.id.split('/')[0];
const channel = this.coms.channels.findBy('sockethubChannelId', channelId);
if (channel) {
this.observeChannel(channel);
this.queryAttendance(channel);
} else {
console.warn('Could not find channel for join message', message);
}
Expand Down Expand Up @@ -263,9 +263,9 @@ export default class SockethubXmppService extends Service {
* @param {Channel} channel
* @public
*/
observeChannel (channel) {
let observeMsg = buildActivityObject(channel.account, {
type: 'observe',
queryAttendance (channel) {
let msg = buildActivityObject(channel.account, {
type: 'query',
target: {
id: channel.sockethubChannelId,
type: 'room'
Expand All @@ -275,8 +275,8 @@ export default class SockethubXmppService extends Service {
}
});

this.log('xmpp', 'asking for attendance list', observeMsg);
this.sockethub.socket.emit('message', observeMsg);
this.log('xmpp', 'asking for attendance list', msg);
this.sockethub.socket.emit('message', msg);
}

/**
Expand Down

0 comments on commit a308579

Please sign in to comment.