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

feat(plugin-presence): upgrade to apheleiav2 and usersub #3613

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions packages/@webex/plugin-presence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> Plugin for the Presence service
Plugin for the Presence service in Webex. The presence plugin provides a set of methods to work with compositions as well as subscriptions of the presence status of users.

- [Install](#install)
- [Usage](#usage)
Expand Down Expand Up @@ -33,7 +33,7 @@ This package is maintained by [Cisco Webex for Developers](https://developer.web

## Contribute

Pull requests are welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
Pull requests are welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/next/CONTRIBUTING.md) for more details.

## License

Expand Down
7 changes: 7 additions & 0 deletions packages/@webex/plugin-presence/src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Presence from './presence';
import PresenceBatcher from './presence-batcher';
import PresenceWorker from './presence-worker';

export * from './presence.type';

export {Presence, PresenceBatcher, PresenceWorker};
5 changes: 4 additions & 1 deletion packages/@webex/plugin-presence/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {has} from 'lodash';

import Presence from './presence';
import config from './config';
import {IPredicate, IResponse, ITransform} from './interface';
import {IPredicate, IResponse, ITransform} from './presence.type';

registerPlugin('presence', Presence, {
payloadTransformer: {
Expand All @@ -18,6 +18,9 @@ registerPlugin('presence', Presence, {
name: 'normalizeSingleStatusResponse',
direction: 'inbound',
test(ctx, response: IResponse) {
/**
* TODO: Might have to change this.
*/
// POST to /apheleia/api/v1/events
return Promise.resolve(has(response, 'body.eventType') && has(response, 'body.subject'));
},
Expand Down
82 changes: 0 additions & 82 deletions packages/@webex/plugin-presence/src/interface.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/@webex/plugin-presence/src/presence-batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import {Batcher} from '@webex/webex-core';
import {IPresenceBatcher} from './interface';
import {IPresenceBatcher} from './presence.type';

/**
* @class
Expand Down
36 changes: 20 additions & 16 deletions packages/@webex/plugin-presence/src/presence-worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {debounce} from 'lodash';

import {IGenericKeyValue, IWebex} from './interface';
import {IGenericKeyValue, IWebex} from './presence.type';
import {
FETCH_DELAY,
GROUNDSKEEPER_INTERVAL,
Expand Down Expand Up @@ -144,21 +144,25 @@ export default class PresenceWorker {
Object.assign(this.flights, boarding);
this.fetchers = {};

this.webex.presence.list(Object.keys(boarding)).then((response) => {
const now = new Date().getTime();

response.statusList.forEach((presence) => {
const id = presence.subject;

delete this.flights[id];
this.presences[id] = now;
});

this.webex.presence.emitEvent(PRESENCE_UPDATE, {
type: ENVELOPE_TYPE.PRESENCE,
payload: response,
});
});
/**
* TODO: webex.presence.list is no longer present. How do we handle this?
* Should we just subscribe?
*/
// this.webex.presence.list(Object.keys(boarding)).then((response) => {
// const now = new Date().getTime();

// response.statusList.forEach((presence) => {
// const id = presence.subject;

// delete this.flights[id];
// this.presences[id] = now;
// });

// this.webex.presence.emitEvent(PRESENCE_UPDATE, {
// type: ENVELOPE_TYPE.PRESENCE,
// payload: response,
// });
// });
}

debouncedFetch = debounce(this.checkFetchers, FETCH_DELAY);
Expand Down
Loading
Loading