@webex/plugin-rooms 3.0.0-beta.14 → 3.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,15 +29,12 @@ npm install --save @webex/plugin-rooms
29
29
  ## Usage
30
30
 
31
31
  ```js
32
-
33
32
  const Webex = require('webex');
34
33
 
35
34
  const webex = Webex.init();
36
- webex.rooms.get(id)
37
- .then((room) => {
38
- console.log(room);
39
- })
40
-
35
+ webex.rooms.get(id).then((room) => {
36
+ console.log(room);
37
+ });
41
38
  ```
42
39
 
43
40
  ## Maintainers
package/dist/rooms.js CHANGED
@@ -550,7 +550,7 @@ var Rooms = _webexCore.WebexPlugin.extend({
550
550
  return null;
551
551
  }
552
552
  },
553
- version: "3.0.0-beta.14"
553
+ version: "3.0.0-beta.15"
554
554
  });
555
555
 
556
556
  var _default = Rooms;
package/dist/rooms.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["debug","require","Rooms","WebexPlugin","extend","listen","createEventEnvelope","webex","SDK_EVENT","EXTERNAL","RESOURCE","ROOMS","then","envelope","eventEnvelope","internal","mercury","connect","listenTo","INTERNAL","WEBEX_ACTIVITY","event","onWebexApiEvent","create","room","request","method","service","resource","body","res","get","options","id","qs","items","list","Page","listWithReadStatus","maxRecent","now","Date","activitiesLimit","computeTitleIfEmpty","conversationsLimit","isActive","sinceDate","setDate","getDate","reject","Error","services","waitForCatalog","conversation","conversations","buildRoomInfoList","getWithReadStatus","roomId","deconstructedId","deconstructHydraId","cluster","convo","buildRoomInfo","remove","statusCode","undefined","update","activity","data","verb","ACTIVITY_VERB","CREATE","roomCreatedEvent","getRoomEvent","EVENT_TYPE","CREATED","trigger","UPDATE","LOCK","UNLOCK","roomUpdatedEvent","UPDATED","sdkEvent","getHydraClusterString","url","tags","object","created","published","actorId","buildHydraPersonId","actor","entryUUID","buildHydraRoomId","target","creatorId","lastActivity","creatorUUID","type","getHydraRoomType","isLocked","includes","ACTIVITY_TAG","LOCKED","e","logger","error","message","title","displayName","computedTitle","lastActivityDate","lastReadableActivityDate","lastRelevantActivityDate","roomInfo","lastSeenActivityDate","toISOString","resolve","roomReadInfo","roomInfoPromises","push","all","roomInfoList","sort","a","b"],"sources":["rooms.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {cloneDeep} from 'lodash';\nimport {\n SDK_EVENT,\n createEventEnvelope,\n buildHydraPersonId,\n buildHydraRoomId,\n getHydraClusterString,\n getHydraRoomType,\n deconstructHydraId\n} from '@webex/common';\n\nconst debug = require('debug')('rooms');\n\n/**\n * @typedef {Object} RoomObject\n * @property {string} id - (server generated) Unique identifier for the room\n * @property {string} title - The display name for the room. All room members\n * will see the title so make it something good\n * @property {string} teamId - (optional) The ID of the team to which the room\n * belongs\n * @property {isoDate} created - (server generated) The date and time that the\n * room was created\n */\n\n/**\n * Rooms are virtual meeting places for getting stuff done. This resource\n * represents the room itself. Check out the {@link Memberships} API to learn\n * how to add and remove people from rooms and the {@link Messages} API for\n * posting and managing content.\n * @class\n * @name Rooms\n */\nconst Rooms = WebexPlugin.extend({\n /**\n * Register to listen for incoming rooms events\n * This is an alternate approach to registering for rooms webhooks.\n * The events passed to any registered handlers will be similar to the webhook JSON,\n * but will omit webhook specific fields such as name, secret, url, etc.\n * To utilize the `listen()` method, the authorization token used\n * will need to have `spark:all` and `spark:kms` scopes enabled.\n * Note that by configuring your application to enable or disable `spark:all`\n * via its configuration page will also enable or disable `spark:kms`.\n * See the <a href=\"https://webex.github.io/webex-js-sdk/samples/browser-socket/\">Sample App</a>\n * for more details.\n * @instance\n * @memberof Rooms\n * @returns {Promise}\n * @example\n * webex.rooms.listen()\n * .then(() => {\n * console.log('listening to room events');\n * webex.rooms.on('created', (event) => console.log(`Got a room:created event:\\n${event}`);\n * webex.rooms.on('updated', (event) => console.log(`Got a room:updated event:\\n${event}`);\n * })\n * .catch((e) => console.error(`Unable to register for room events: ${e}`));\n * // Some app logic...\n * // WHen it is time to cleanup\n * webex.rooms.stopListening();\n * webex.rooms.off('created');\n * webex.rooms.off('updated');\n */\n listen() {\n return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ROOMS)\n .then((envelope) => {\n this.eventEnvelope = envelope;\n\n return this.webex.internal.mercury.connect().then(() => {\n this.listenTo(this.webex.internal.mercury,\n SDK_EVENT.INTERNAL.WEBEX_ACTIVITY,\n (event) => this.onWebexApiEvent(event));\n });\n });\n },\n\n /**\n * Creates a new room. The authenticated user is automatically added as a\n * member of the room. See the {@link Memberships} API to learn how to add\n * more people to the room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject} room\n * @returns {Promise<RoomObject>}\n * @example\n * webex.rooms.create({title: 'Create Room Example'})\n * .then(function(room) {\n * var assert = require('assert')\n * assert(typeof room.created === 'string');\n * assert(typeof room.id === 'string');\n * assert(room.title === 'Create Room Example');\n * console.log(room.title);\n * return 'success';\n * });\n * // => success\n */\n create(room) {\n return this.request({\n method: 'POST',\n service: 'hydra',\n resource: 'rooms',\n body: room\n })\n .then((res) => res.body);\n },\n\n /**\n * Returns a single room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject|string} room\n * @param {Object} options\n * @returns {Promise<RoomObject>}\n * @example\n * var room;\n * webex.rooms.create({title: 'Get Room Example'})\n * .then(function(r) {\n * room = r\n * return webex.rooms.get(room.id)\n * })\n * .then(function(r) {\n * var assert = require('assert');\n * assert.deepEqual(r, room);\n * return 'success';\n * });\n * // => success\n */\n get(room, options) {\n const id = room.id || room;\n\n return this.request({\n service: 'hydra',\n resource: `rooms/${id}`,\n qs: options\n })\n .then((res) => res.body.items || res.body);\n },\n\n /**\n * Returns a list of rooms. In most cases the results will only contain rooms\n * that the authenticated user is a member of.\n * @instance\n * @memberof Rooms\n * @param {Object} options\n * @param {Object} options.max Limit the maximum number of rooms in the\n * response.\n * @returns {Promise<Page<RoomObject>>}\n * @example\n * var createdRooms;\n * Promise.all([\n * webex.rooms.create({title: 'List Rooms Example 1'}),\n * webex.rooms.create({title: 'List Rooms Example 2'}),\n * webex.rooms.create({title: 'List Rooms Example 3'})\n * ])\n * .then(function(r) {\n * createdRooms = r;\n * return webex.rooms.list({max: 3})\n * .then(function(rooms) {\n * var assert = require('assert');\n * assert(rooms.length === 3);\n * for (var i = 0; i < rooms.items.length; i+= 1) {\n * assert(createdRooms.filter(function(room) {\n * return room.id === rooms.items[i].id;\n * }).length === 1);\n * }\n * return 'success';\n * });\n * });\n * // => success\n */\n list(options) {\n return this.request({\n service: 'hydra',\n resource: 'rooms/',\n qs: options\n })\n .then((res) => new Page(res, this.webex));\n },\n\n /**\n * Returns a list of rooms with details about the data of the last\n * activity in the room, and the date of the users last presences in\n * the room. The list is sorted with this with most recent activity first\n *\n * For rooms where lastActivityDate > lastSeenDate the space\n * can be considered to be \"unread\"\n *\n * This differs from the rooms.list() function in the following ways:\n * -- when called with no parameters it returns an array of all\n * spaces, up to 1000, that the user is a member of\n * -- pagination is not supported. ALL rooms are returned which\n * can result in a large payload\n * -- For users with hundreds of spaces, this API can take some time to\n * to return, for this reason it supports an optional maxRecent parameter.\n * If set this will return only the specified number of spaces with activity\n * in the last two weeks. Recommended value is 30. Max supported is 100.\n * -- only \"id\", \"type\", \"lastActivityDate\", and \"lastSeenDate\" are\n * guaranteed to be available for each room in the list\n * -- \"title\" is usually returned, but not guaranteed\n *\n * In general this function should be used only when the client needs to\n * access read status info, for example on startup.\n * After startup, clients should track message and membership:seen events\n * to maintain read status client side.\n *\n * Since this API can take some time to return up to 1000 spaces, it is\n * recommended that custom clients call this first with the maxRecent parameter\n * set to 30, so that they can display some of the more recents spaces. Calling\n * this API a second time with no parameters will return all the spaces.\n *\n * Not all spaces may be returned, for example when users in more than 1000\n * spaces, or when a new spaces is added after this function is called,\n * but before it returns. Custom clients should be prepared to gracefully\n * handle cases where an event occurs in a space not returned by this call,\n * by querying rooms.getWithReadStatus() with the id of the room in question\n *\n * This function may be deprecated when this info is provided in the membership\n * objects returned in the list function.\n * @instance\n * @param {int} maxRecent\n * @memberof Rooms\n * @returns {Promise<RoomInfoObjectList>}\n */\n async listWithReadStatus(maxRecent = 0) {\n const now = new Date();\n const options = {\n activitiesLimit: 0,\n computeTitleIfEmpty: true,\n conversationsLimit: 1000,\n isActive: true\n };\n\n if (maxRecent > 0) {\n options.conversationsLimit = maxRecent;\n options.sinceDate = now.setDate(now.getDate() - 14);\n }\n else if ((maxRecent < 0) || (maxRecent > 100)) {\n return Promise.reject(new Error('rooms.listWithReadStatus: ' +\n 'optional maxRecent parameter must be an integer between 1 and 100'));\n }\n\n return this.webex.internal.services.waitForCatalog('postauth')\n .then(() => this.webex.internal.conversation.list(options))\n .then((conversations) => buildRoomInfoList(this.webex, conversations));\n },\n\n /**\n * Returns a single room object with details about the data of the last\n * activity in the room, and the date of the users last presence in\n * the room.\n *\n * For rooms where lastActivityDate > lastSeenDate the room\n * can be considered to be \"unread\"\n *\n * This differs from the rooms.get() function in the following ways:\n * -- it takes a single roomId parameter to fetch\n * -- no other options are considered\n * -- only \"id\", \"type\", \"lastActivityDate\", and \"lastSeenDate\" are\n * guaranteed to be available in the return object\n * -- \"title\" is usually returned, but not guaranteed\n *\n * In general clients should use the listWithReadStatus() method on startup\n * to get the initial roomStatus and then update their client side copy by\n * responding to message, membership and room events.\n\n * This function allows a custom client to be \"nimble\" if it is responding\n * to an event with a roomId that was not in the original fetch. The\n * anticipated behavior is that getWithReadStats is called \"just in time\",\n * with the resulting room object being added to the list of cached room\n * objects on the client side.\n *\n * This function may be deprecated when this info is provided in the room\n * object returned in the get function.\n * @instance\n * @memberof Rooms\n * @param {string} roomId\n * @returns {Promise<RoomInfoObject>}\n */\n getWithReadStatus(roomId) {\n const deconstructedId = deconstructHydraId(roomId);\n const conversation = {\n id: deconstructedId.id,\n cluster: deconstructedId.cluster\n };\n\n return this.webex.internal.services.waitForCatalog('postauth')\n .then(() => this.webex.internal.conversation.get(conversation,\n {\n computeTitleIfEmpty: true,\n activitiesLimit: 0 // don't send the whole history of activity\n })\n .then((convo) => buildRoomInfo(this.webex, convo)));\n },\n\n /**\n * Deletes a single room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject|string} room\n * @returns {Promise}\n * @example\n * var room;\n * webex.rooms.create({title: 'Remove Room Example'})\n * .then(function(r) {\n * room = r;\n * return webex.rooms.remove(room.id);\n * })\n * .then(function() {\n * return webex.rooms.get(room.id);\n * })\n * .then(function() {\n * var assert = require('assert');\n * assert(false, 'the previous get should have failed');\n * })\n * .catch(function(reason) {\n * var assert = require('assert');\n * assert.equal(reason.statusCode, 404);\n * return 'success'\n * });\n * // => success\n */\n remove(room) {\n const id = room.id || room;\n\n return this.request({\n method: 'DELETE',\n service: 'hydra',\n resource: `rooms/${id}`\n })\n .then((res) => {\n // Firefox has some issues with 204s and/or DELETE. This should move to\n // http-core\n if (res.statusCode === 204) {\n return undefined;\n }\n\n return res.body;\n });\n },\n\n /**\n * Used to update a single room's properties.\n * @instance\n * @memberof Rooms\n * @param {RoomObject} room\n * @returns {Promise<RoomObject>}\n * @example\n * var room;\n * webex.rooms.update({title: 'Update Room Example'})\n * .then(function(r) {\n * room = r;\n * room.title = 'Update Room Example (Updated Title)';\n * return webex.rooms.update(room);\n * })\n * .then(function() {\n * return webex.rooms.get(room.id);\n * })\n * .then(function(room) {\n * var assert = require('assert');\n * assert.equal(room.title, 'Update Room Example (Updated Title)');\n * return 'success';\n * });\n * // => success\n */\n update(room) {\n const {id} = room;\n\n return this.request({\n method: 'PUT',\n service: 'hydra',\n resource: `rooms/${id}`,\n body: room\n })\n .then((res) => res.body);\n },\n\n /**\n * This function is called when an internal membership events fires,\n * if the user registered for these events with the listen() function.\n * External users of the SDK should not call this function\n * @private\n * @memberof Rooms\n * @param {Object} event\n * @returns {void}\n */\n onWebexApiEvent(event) {\n const {activity} = event.data;\n\n /* eslint-disable no-case-declarations */\n switch (activity.verb) {\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.CREATE:\n const roomCreatedEvent =\n this.getRoomEvent(this.webex, activity, SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED);\n\n if (roomCreatedEvent) {\n debug(`room \"created\" payload: \\\n ${JSON.stringify(roomCreatedEvent)}`);\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED, roomCreatedEvent);\n }\n break;\n\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.UPDATE:\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.LOCK:\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.UNLOCK:\n debug(`generating a rooms:updated based on ${activity.verb} activity`);\n const roomUpdatedEvent =\n this.getRoomEvent(this.webex, activity, SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED);\n\n if (roomUpdatedEvent) {\n debug(`room \"updated\" payload: \\\n ${JSON.stringify(roomUpdatedEvent)}`);\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED, roomUpdatedEvent);\n }\n break;\n\n default:\n break;\n }\n },\n\n /**\n * Constructs the data object for an event on the rooms resource,\n * adhering to Hydra's Webhook data structure.\n * External users of the SDK should not call this function\n * @private\n * @memberof Rooms\n * @param {Object} webex sdk instance\n * @param {Object} activity from mercury\n * @param {Object} event type of \"webhook\" event\n * @returns {Object} constructed event\n */\n getRoomEvent(webex, activity, event) {\n try {\n const sdkEvent = cloneDeep(this.eventEnvelope);\n const cluster = getHydraClusterString(webex, activity.url);\n let {tags} = activity.object;\n\n sdkEvent.event = event;\n sdkEvent.data.created = activity.published;\n sdkEvent.actorId = buildHydraPersonId(activity.actor.entryUUID, cluster);\n if (activity.object.id) {\n sdkEvent.data.id = buildHydraRoomId(activity.object.id, cluster);\n }\n else {\n sdkEvent.data.id = buildHydraRoomId(activity.target.id, cluster);\n }\n\n if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED) {\n sdkEvent.data.creatorId = buildHydraPersonId(activity.actor.entryUUID, cluster);\n sdkEvent.data.lastActivity = activity.published;\n }\n else if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED) {\n if (activity.verb === 'update') {\n // For some reason the tags are not in the object for an update activity\n tags = activity.target.tags;\n }\n if (activity.object.creatorUUID) {\n // This seems to be set in lock/unlock activities but not updated...\n debug(`Found a creatorId: ${activity.object.creatorUUID} in a ${activity.verb} event`);\n sdkEvent.data.creatorId = buildHydraPersonId(activity.object.creatorUUID, cluster);\n }\n // Webhook engine team sets this based on lastReadableActivityDate\n // in the activity.target object. See: hydra/HydraRoom.java#L51\n // This elements seems to be missing from the activity that the SDK is getting\n // sdkEvent.data.lastActivity = activity.target.lastReadableActivityDate;\n }\n else {\n throw new Error('unexpected event type');\n }\n sdkEvent.data.type = getHydraRoomType(tags);\n sdkEvent.data.isLocked =\n tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.LOCKED);\n\n return sdkEvent;\n }\n catch (e) {\n this.webex.logger.error(`Unable to generate SDK event from mercury socket activity for rooms:${event} event: ${e.message}`);\n\n return null;\n }\n }\n\n});\n\nexport default Rooms;\n\n/**\n * Helper method to build a roomInfo object from a conversation object\n * @param {Object} webex sdk object\n * @param {Conversation~ConversationObject} conversation\n * @returns {Promise<RoomInfoObject>}\n */\nasync function buildRoomInfo(webex, conversation) {\n try {\n const type = getHydraRoomType(conversation.tags);\n const cluster = getHydraClusterString(webex, conversation.url);\n const title = conversation.displayName ?\n conversation.displayName : conversation.computedTitle;\n const lastActivityDate = conversation.lastReadableActivityDate ?\n conversation.lastReadableActivityDate :\n conversation.lastRelevantActivityDate;\n\n const roomInfo = {\n id: buildHydraRoomId(conversation.id, cluster),\n type,\n ...(title && {title: conversation.displayName}),\n ...(lastActivityDate && {lastActivityDate}),\n lastSeenActivityDate: conversation.lastSeenActivityDate ?\n conversation.lastSeenActivityDate :\n // If user has never been seen set the date to \"a long time ago\"\n new Date(0).toISOString()\n };\n\n return Promise.resolve(roomInfo);\n }\n catch (e) {\n return Promise.reject(e);\n }\n}\n\n/**\n * Helper method to build a list of roomInfo object from conversation list\n * @param {Object} webex sdk object\n * @param {Conversation~ConversationObjectList} conversations\n * @returns {Promise<RoomInfoList>}\n */\nasync function buildRoomInfoList(webex, conversations) {\n // Convert each Conversation into a roomInfo object\n const roomReadInfo = {items: []};\n const roomInfoPromises = [];\n\n for (const conversation of conversations) {\n roomInfoPromises.push(buildRoomInfo(webex, conversation));\n }\n\n return Promise.all(roomInfoPromises)\n .then((roomInfoList) => {\n roomReadInfo.items = roomInfoList;\n roomReadInfo.items.sort((a, b) => (a.lastActivityDate < b.lastActivityDate ? 1 : -1));\n\n return roomReadInfo;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAEA;;;;;;;;;;;;AAUA,IAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,OAAjB,CAAd;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMC,KAAK,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAC/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,MA7B+B,oBA6BtB;IAAA;;IACP,OAAO,IAAAC,2BAAA,EAAoB,KAAKC,KAAzB,EAAgCC,iBAAA,CAAUC,QAAV,CAAmBC,QAAnB,CAA4BC,KAA5D,EACJC,IADI,CACC,UAACC,QAAD,EAAc;MAClB,KAAI,CAACC,aAAL,GAAqBD,QAArB;MAEA,OAAO,KAAI,CAACN,KAAL,CAAWQ,QAAX,CAAoBC,OAApB,CAA4BC,OAA5B,GAAsCL,IAAtC,CAA2C,YAAM;QACtD,KAAI,CAACM,QAAL,CAAc,KAAI,CAACX,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A1D;cAAA,CAAxB;cAEA,OAAOO,YAAP;YACD,CANI,CATT;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
1
+ {"version":3,"names":["debug","require","Rooms","WebexPlugin","extend","listen","createEventEnvelope","webex","SDK_EVENT","EXTERNAL","RESOURCE","ROOMS","then","envelope","eventEnvelope","internal","mercury","connect","listenTo","INTERNAL","WEBEX_ACTIVITY","event","onWebexApiEvent","create","room","request","method","service","resource","body","res","get","options","id","qs","items","list","Page","listWithReadStatus","maxRecent","now","Date","activitiesLimit","computeTitleIfEmpty","conversationsLimit","isActive","sinceDate","setDate","getDate","reject","Error","services","waitForCatalog","conversation","conversations","buildRoomInfoList","getWithReadStatus","roomId","deconstructedId","deconstructHydraId","cluster","convo","buildRoomInfo","remove","statusCode","undefined","update","activity","data","verb","ACTIVITY_VERB","CREATE","roomCreatedEvent","getRoomEvent","EVENT_TYPE","CREATED","trigger","UPDATE","LOCK","UNLOCK","roomUpdatedEvent","UPDATED","sdkEvent","getHydraClusterString","url","tags","object","created","published","actorId","buildHydraPersonId","actor","entryUUID","buildHydraRoomId","target","creatorId","lastActivity","creatorUUID","type","getHydraRoomType","isLocked","includes","ACTIVITY_TAG","LOCKED","e","logger","error","message","title","displayName","computedTitle","lastActivityDate","lastReadableActivityDate","lastRelevantActivityDate","roomInfo","lastSeenActivityDate","toISOString","resolve","roomReadInfo","roomInfoPromises","push","all","roomInfoList","sort","a","b"],"sources":["rooms.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {cloneDeep} from 'lodash';\nimport {\n SDK_EVENT,\n createEventEnvelope,\n buildHydraPersonId,\n buildHydraRoomId,\n getHydraClusterString,\n getHydraRoomType,\n deconstructHydraId,\n} from '@webex/common';\n\nconst debug = require('debug')('rooms');\n\n/**\n * @typedef {Object} RoomObject\n * @property {string} id - (server generated) Unique identifier for the room\n * @property {string} title - The display name for the room. All room members\n * will see the title so make it something good\n * @property {string} teamId - (optional) The ID of the team to which the room\n * belongs\n * @property {isoDate} created - (server generated) The date and time that the\n * room was created\n */\n\n/**\n * Rooms are virtual meeting places for getting stuff done. This resource\n * represents the room itself. Check out the {@link Memberships} API to learn\n * how to add and remove people from rooms and the {@link Messages} API for\n * posting and managing content.\n * @class\n * @name Rooms\n */\nconst Rooms = WebexPlugin.extend({\n /**\n * Register to listen for incoming rooms events\n * This is an alternate approach to registering for rooms webhooks.\n * The events passed to any registered handlers will be similar to the webhook JSON,\n * but will omit webhook specific fields such as name, secret, url, etc.\n * To utilize the `listen()` method, the authorization token used\n * will need to have `spark:all` and `spark:kms` scopes enabled.\n * Note that by configuring your application to enable or disable `spark:all`\n * via its configuration page will also enable or disable `spark:kms`.\n * See the <a href=\"https://webex.github.io/webex-js-sdk/samples/browser-socket/\">Sample App</a>\n * for more details.\n * @instance\n * @memberof Rooms\n * @returns {Promise}\n * @example\n * webex.rooms.listen()\n * .then(() => {\n * console.log('listening to room events');\n * webex.rooms.on('created', (event) => console.log(`Got a room:created event:\\n${event}`);\n * webex.rooms.on('updated', (event) => console.log(`Got a room:updated event:\\n${event}`);\n * })\n * .catch((e) => console.error(`Unable to register for room events: ${e}`));\n * // Some app logic...\n * // WHen it is time to cleanup\n * webex.rooms.stopListening();\n * webex.rooms.off('created');\n * webex.rooms.off('updated');\n */\n listen() {\n return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ROOMS).then((envelope) => {\n this.eventEnvelope = envelope;\n\n return this.webex.internal.mercury.connect().then(() => {\n this.listenTo(this.webex.internal.mercury, SDK_EVENT.INTERNAL.WEBEX_ACTIVITY, (event) =>\n this.onWebexApiEvent(event)\n );\n });\n });\n },\n\n /**\n * Creates a new room. The authenticated user is automatically added as a\n * member of the room. See the {@link Memberships} API to learn how to add\n * more people to the room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject} room\n * @returns {Promise<RoomObject>}\n * @example\n * webex.rooms.create({title: 'Create Room Example'})\n * .then(function(room) {\n * var assert = require('assert')\n * assert(typeof room.created === 'string');\n * assert(typeof room.id === 'string');\n * assert(room.title === 'Create Room Example');\n * console.log(room.title);\n * return 'success';\n * });\n * // => success\n */\n create(room) {\n return this.request({\n method: 'POST',\n service: 'hydra',\n resource: 'rooms',\n body: room,\n }).then((res) => res.body);\n },\n\n /**\n * Returns a single room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject|string} room\n * @param {Object} options\n * @returns {Promise<RoomObject>}\n * @example\n * var room;\n * webex.rooms.create({title: 'Get Room Example'})\n * .then(function(r) {\n * room = r\n * return webex.rooms.get(room.id)\n * })\n * .then(function(r) {\n * var assert = require('assert');\n * assert.deepEqual(r, room);\n * return 'success';\n * });\n * // => success\n */\n get(room, options) {\n const id = room.id || room;\n\n return this.request({\n service: 'hydra',\n resource: `rooms/${id}`,\n qs: options,\n }).then((res) => res.body.items || res.body);\n },\n\n /**\n * Returns a list of rooms. In most cases the results will only contain rooms\n * that the authenticated user is a member of.\n * @instance\n * @memberof Rooms\n * @param {Object} options\n * @param {Object} options.max Limit the maximum number of rooms in the\n * response.\n * @returns {Promise<Page<RoomObject>>}\n * @example\n * var createdRooms;\n * Promise.all([\n * webex.rooms.create({title: 'List Rooms Example 1'}),\n * webex.rooms.create({title: 'List Rooms Example 2'}),\n * webex.rooms.create({title: 'List Rooms Example 3'})\n * ])\n * .then(function(r) {\n * createdRooms = r;\n * return webex.rooms.list({max: 3})\n * .then(function(rooms) {\n * var assert = require('assert');\n * assert(rooms.length === 3);\n * for (var i = 0; i < rooms.items.length; i+= 1) {\n * assert(createdRooms.filter(function(room) {\n * return room.id === rooms.items[i].id;\n * }).length === 1);\n * }\n * return 'success';\n * });\n * });\n * // => success\n */\n list(options) {\n return this.request({\n service: 'hydra',\n resource: 'rooms/',\n qs: options,\n }).then((res) => new Page(res, this.webex));\n },\n\n /**\n * Returns a list of rooms with details about the data of the last\n * activity in the room, and the date of the users last presences in\n * the room. The list is sorted with this with most recent activity first\n *\n * For rooms where lastActivityDate > lastSeenDate the space\n * can be considered to be \"unread\"\n *\n * This differs from the rooms.list() function in the following ways:\n * -- when called with no parameters it returns an array of all\n * spaces, up to 1000, that the user is a member of\n * -- pagination is not supported. ALL rooms are returned which\n * can result in a large payload\n * -- For users with hundreds of spaces, this API can take some time to\n * to return, for this reason it supports an optional maxRecent parameter.\n * If set this will return only the specified number of spaces with activity\n * in the last two weeks. Recommended value is 30. Max supported is 100.\n * -- only \"id\", \"type\", \"lastActivityDate\", and \"lastSeenDate\" are\n * guaranteed to be available for each room in the list\n * -- \"title\" is usually returned, but not guaranteed\n *\n * In general this function should be used only when the client needs to\n * access read status info, for example on startup.\n * After startup, clients should track message and membership:seen events\n * to maintain read status client side.\n *\n * Since this API can take some time to return up to 1000 spaces, it is\n * recommended that custom clients call this first with the maxRecent parameter\n * set to 30, so that they can display some of the more recents spaces. Calling\n * this API a second time with no parameters will return all the spaces.\n *\n * Not all spaces may be returned, for example when users in more than 1000\n * spaces, or when a new spaces is added after this function is called,\n * but before it returns. Custom clients should be prepared to gracefully\n * handle cases where an event occurs in a space not returned by this call,\n * by querying rooms.getWithReadStatus() with the id of the room in question\n *\n * This function may be deprecated when this info is provided in the membership\n * objects returned in the list function.\n * @instance\n * @param {int} maxRecent\n * @memberof Rooms\n * @returns {Promise<RoomInfoObjectList>}\n */\n async listWithReadStatus(maxRecent = 0) {\n const now = new Date();\n const options = {\n activitiesLimit: 0,\n computeTitleIfEmpty: true,\n conversationsLimit: 1000,\n isActive: true,\n };\n\n if (maxRecent > 0) {\n options.conversationsLimit = maxRecent;\n options.sinceDate = now.setDate(now.getDate() - 14);\n } else if (maxRecent < 0 || maxRecent > 100) {\n return Promise.reject(\n new Error(\n 'rooms.listWithReadStatus: ' +\n 'optional maxRecent parameter must be an integer between 1 and 100'\n )\n );\n }\n\n return this.webex.internal.services\n .waitForCatalog('postauth')\n .then(() => this.webex.internal.conversation.list(options))\n .then((conversations) => buildRoomInfoList(this.webex, conversations));\n },\n\n /**\n * Returns a single room object with details about the data of the last\n * activity in the room, and the date of the users last presence in\n * the room.\n *\n * For rooms where lastActivityDate > lastSeenDate the room\n * can be considered to be \"unread\"\n *\n * This differs from the rooms.get() function in the following ways:\n * -- it takes a single roomId parameter to fetch\n * -- no other options are considered\n * -- only \"id\", \"type\", \"lastActivityDate\", and \"lastSeenDate\" are\n * guaranteed to be available in the return object\n * -- \"title\" is usually returned, but not guaranteed\n *\n * In general clients should use the listWithReadStatus() method on startup\n * to get the initial roomStatus and then update their client side copy by\n * responding to message, membership and room events.\n\n * This function allows a custom client to be \"nimble\" if it is responding\n * to an event with a roomId that was not in the original fetch. The\n * anticipated behavior is that getWithReadStats is called \"just in time\",\n * with the resulting room object being added to the list of cached room\n * objects on the client side.\n *\n * This function may be deprecated when this info is provided in the room\n * object returned in the get function.\n * @instance\n * @memberof Rooms\n * @param {string} roomId\n * @returns {Promise<RoomInfoObject>}\n */\n getWithReadStatus(roomId) {\n const deconstructedId = deconstructHydraId(roomId);\n const conversation = {\n id: deconstructedId.id,\n cluster: deconstructedId.cluster,\n };\n\n return this.webex.internal.services.waitForCatalog('postauth').then(() =>\n this.webex.internal.conversation\n .get(conversation, {\n computeTitleIfEmpty: true,\n activitiesLimit: 0, // don't send the whole history of activity\n })\n .then((convo) => buildRoomInfo(this.webex, convo))\n );\n },\n\n /**\n * Deletes a single room.\n * @instance\n * @memberof Rooms\n * @param {RoomObject|string} room\n * @returns {Promise}\n * @example\n * var room;\n * webex.rooms.create({title: 'Remove Room Example'})\n * .then(function(r) {\n * room = r;\n * return webex.rooms.remove(room.id);\n * })\n * .then(function() {\n * return webex.rooms.get(room.id);\n * })\n * .then(function() {\n * var assert = require('assert');\n * assert(false, 'the previous get should have failed');\n * })\n * .catch(function(reason) {\n * var assert = require('assert');\n * assert.equal(reason.statusCode, 404);\n * return 'success'\n * });\n * // => success\n */\n remove(room) {\n const id = room.id || room;\n\n return this.request({\n method: 'DELETE',\n service: 'hydra',\n resource: `rooms/${id}`,\n }).then((res) => {\n // Firefox has some issues with 204s and/or DELETE. This should move to\n // http-core\n if (res.statusCode === 204) {\n return undefined;\n }\n\n return res.body;\n });\n },\n\n /**\n * Used to update a single room's properties.\n * @instance\n * @memberof Rooms\n * @param {RoomObject} room\n * @returns {Promise<RoomObject>}\n * @example\n * var room;\n * webex.rooms.update({title: 'Update Room Example'})\n * .then(function(r) {\n * room = r;\n * room.title = 'Update Room Example (Updated Title)';\n * return webex.rooms.update(room);\n * })\n * .then(function() {\n * return webex.rooms.get(room.id);\n * })\n * .then(function(room) {\n * var assert = require('assert');\n * assert.equal(room.title, 'Update Room Example (Updated Title)');\n * return 'success';\n * });\n * // => success\n */\n update(room) {\n const {id} = room;\n\n return this.request({\n method: 'PUT',\n service: 'hydra',\n resource: `rooms/${id}`,\n body: room,\n }).then((res) => res.body);\n },\n\n /**\n * This function is called when an internal membership events fires,\n * if the user registered for these events with the listen() function.\n * External users of the SDK should not call this function\n * @private\n * @memberof Rooms\n * @param {Object} event\n * @returns {void}\n */\n onWebexApiEvent(event) {\n const {activity} = event.data;\n\n /* eslint-disable no-case-declarations */\n switch (activity.verb) {\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.CREATE:\n const roomCreatedEvent = this.getRoomEvent(\n this.webex,\n activity,\n SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED\n );\n\n if (roomCreatedEvent) {\n debug(`room \"created\" payload: \\\n ${JSON.stringify(roomCreatedEvent)}`);\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED, roomCreatedEvent);\n }\n break;\n\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.UPDATE:\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.LOCK:\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.UNLOCK:\n debug(`generating a rooms:updated based on ${activity.verb} activity`);\n const roomUpdatedEvent = this.getRoomEvent(\n this.webex,\n activity,\n SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED\n );\n\n if (roomUpdatedEvent) {\n debug(`room \"updated\" payload: \\\n ${JSON.stringify(roomUpdatedEvent)}`);\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED, roomUpdatedEvent);\n }\n break;\n\n default:\n break;\n }\n },\n\n /**\n * Constructs the data object for an event on the rooms resource,\n * adhering to Hydra's Webhook data structure.\n * External users of the SDK should not call this function\n * @private\n * @memberof Rooms\n * @param {Object} webex sdk instance\n * @param {Object} activity from mercury\n * @param {Object} event type of \"webhook\" event\n * @returns {Object} constructed event\n */\n getRoomEvent(webex, activity, event) {\n try {\n const sdkEvent = cloneDeep(this.eventEnvelope);\n const cluster = getHydraClusterString(webex, activity.url);\n let {tags} = activity.object;\n\n sdkEvent.event = event;\n sdkEvent.data.created = activity.published;\n sdkEvent.actorId = buildHydraPersonId(activity.actor.entryUUID, cluster);\n if (activity.object.id) {\n sdkEvent.data.id = buildHydraRoomId(activity.object.id, cluster);\n } else {\n sdkEvent.data.id = buildHydraRoomId(activity.target.id, cluster);\n }\n\n if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED) {\n sdkEvent.data.creatorId = buildHydraPersonId(activity.actor.entryUUID, cluster);\n sdkEvent.data.lastActivity = activity.published;\n } else if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED) {\n if (activity.verb === 'update') {\n // For some reason the tags are not in the object for an update activity\n tags = activity.target.tags;\n }\n if (activity.object.creatorUUID) {\n // This seems to be set in lock/unlock activities but not updated...\n debug(`Found a creatorId: ${activity.object.creatorUUID} in a ${activity.verb} event`);\n sdkEvent.data.creatorId = buildHydraPersonId(activity.object.creatorUUID, cluster);\n }\n // Webhook engine team sets this based on lastReadableActivityDate\n // in the activity.target object. See: hydra/HydraRoom.java#L51\n // This elements seems to be missing from the activity that the SDK is getting\n // sdkEvent.data.lastActivity = activity.target.lastReadableActivityDate;\n } else {\n throw new Error('unexpected event type');\n }\n sdkEvent.data.type = getHydraRoomType(tags);\n sdkEvent.data.isLocked = tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.LOCKED);\n\n return sdkEvent;\n } catch (e) {\n this.webex.logger.error(\n `Unable to generate SDK event from mercury socket activity for rooms:${event} event: ${e.message}`\n );\n\n return null;\n }\n },\n});\n\nexport default Rooms;\n\n/**\n * Helper method to build a roomInfo object from a conversation object\n * @param {Object} webex sdk object\n * @param {Conversation~ConversationObject} conversation\n * @returns {Promise<RoomInfoObject>}\n */\nasync function buildRoomInfo(webex, conversation) {\n try {\n const type = getHydraRoomType(conversation.tags);\n const cluster = getHydraClusterString(webex, conversation.url);\n const title = conversation.displayName ? conversation.displayName : conversation.computedTitle;\n const lastActivityDate = conversation.lastReadableActivityDate\n ? conversation.lastReadableActivityDate\n : conversation.lastRelevantActivityDate;\n\n const roomInfo = {\n id: buildHydraRoomId(conversation.id, cluster),\n type,\n ...(title && {title: conversation.displayName}),\n ...(lastActivityDate && {lastActivityDate}),\n lastSeenActivityDate: conversation.lastSeenActivityDate\n ? conversation.lastSeenActivityDate\n : // If user has never been seen set the date to \"a long time ago\"\n new Date(0).toISOString(),\n };\n\n return Promise.resolve(roomInfo);\n } catch (e) {\n return Promise.reject(e);\n }\n}\n\n/**\n * Helper method to build a list of roomInfo object from conversation list\n * @param {Object} webex sdk object\n * @param {Conversation~ConversationObjectList} conversations\n * @returns {Promise<RoomInfoList>}\n */\nasync function buildRoomInfoList(webex, conversations) {\n // Convert each Conversation into a roomInfo object\n const roomReadInfo = {items: []};\n const roomInfoPromises = [];\n\n for (const conversation of conversations) {\n roomInfoPromises.push(buildRoomInfo(webex, conversation));\n }\n\n return Promise.all(roomInfoPromises).then((roomInfoList) => {\n roomReadInfo.items = roomInfoList;\n roomReadInfo.items.sort((a, b) => (a.lastActivityDate < b.lastActivityDate ? 1 : -1));\n\n return roomReadInfo;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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AJY,CAAb,EAKJZ,IALI,CAKC,UAACkB,GAAD;MAAA,OAASA,GAAG,CAACD,IAAb;IAAA,CALD,CAAP;EAMD,CApE8B;;EAsE/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,GA3F+B,eA2F3BP,IA3F2B,EA2FrBQ,OA3FqB,EA2FZ;IACjB,IAAMC,EAAE,GAAGT,IAAI,CAACS,EAAL,IAAWT,IAAtB;IAEA,OAAO,KAAKC,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,kBAAWK,EAAX,CAFU;MAGlBC,EAAE,EAAEF;IAHc,CAAb,EAIJpB,IAJI,CAIC,UAACkB,GAAD;MAAA,OAASA,GAAG,CAACD,IAAJ,CAASM,KAAT,IAAkBL,GAAG,CAACD,IAA/B;IAAA,CAJD,CAAP;EAKD,CAnG8B;;EAqG/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,IArI+B,gBAqI1BJ,OArI0B,EAqIjB;IAAA;;IACZ,OAAO,KAAKP,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,EAAE,QAFQ;MAGlBM,EAAE,EAAEF;IAHc,CAAb,EAIJpB,IAJI,CAIC,UAACkB,GAAD;MAAA,OAAS,IAAIO,eAAJ,CAASP,GAAT,EAAc,MAAI,CAACvB,KAAnB,CAAT;IAAA,CAJD,CAAP;EAKD,CA3I8B;;EA6I/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAA;YAAA;YAAA,kCAsBW,iBAAQjE,MAAR,cAtBX;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C;;;;SAgCeM,iB;;;;;+FAAf,kBAAiChD,KAAjC,EAAwC+C,aAAxC;IAAA;;IAAA;MAAA;QAAA;UAAA;YACE;YACMgE,YAFR,GAEuB;cAACnF,KAAK,EAAE;YAAR,CAFvB;YAGQoF,gBAHR,GAG2B,EAH3B;YAAA,uCAK6BjE,aAL7B;;YAAA;cAKE,oDAA0C;gBAA/BD,YAA+B;gBACxCkE,gBAAgB,CAACC,IAAjB,CAAsB1D,aAAa,CAACvD,KAAD,EAAQ8C,YAAR,CAAnC;cACD;YAPH;cAAA;YAAA;cAAA;YAAA;;YAAA,kCASS,iBAAQoE,GAAR,CAAYF,gBAAZ,EAA8B3G,IAA9B,CAAmC,UAAC8G,YAAD,EAAkB;cAC1DJ,YAAY,CAACnF,KAAb,GAAqBuF,YAArB;cACAJ,YAAY,CAACnF,KAAb,CAAmBwF,IAAnB,CAAwB,UAACC,CAAD,EAAIC,CAAJ;gBAAA,OAAWD,CAAC,CAACb,gBAAF,GAAqBc,CAAC,CAACd,gBAAvB,GAA0C,CAA1C,GAA8C,CAAC,CAA1D;cAAA,CAAxB;cAEA,OAAOO,YAAP;YACD,CALM,CATT;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-rooms",
3
- "version": "3.0.0-beta.14",
3
+ "version": "3.0.0-beta.15",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,20 +20,20 @@
20
20
  ]
21
21
  },
22
22
  "devDependencies": {
23
- "@webex/test-helper-chai": "3.0.0-beta.14",
24
- "@webex/test-helper-test-users": "3.0.0-beta.14",
23
+ "@webex/test-helper-chai": "3.0.0-beta.15",
24
+ "@webex/test-helper-test-users": "3.0.0-beta.15",
25
25
  "sinon": "^9.2.4"
26
26
  },
27
27
  "dependencies": {
28
- "@webex/common": "3.0.0-beta.14",
29
- "@webex/internal-plugin-conversation": "3.0.0-beta.14",
30
- "@webex/internal-plugin-mercury": "3.0.0-beta.14",
31
- "@webex/plugin-logger": "3.0.0-beta.14",
32
- "@webex/plugin-memberships": "3.0.0-beta.14",
33
- "@webex/plugin-messages": "3.0.0-beta.14",
34
- "@webex/plugin-people": "3.0.0-beta.14",
35
- "@webex/plugin-rooms": "3.0.0-beta.14",
36
- "@webex/webex-core": "3.0.0-beta.14",
28
+ "@webex/common": "3.0.0-beta.15",
29
+ "@webex/internal-plugin-conversation": "3.0.0-beta.15",
30
+ "@webex/internal-plugin-mercury": "3.0.0-beta.15",
31
+ "@webex/plugin-logger": "3.0.0-beta.15",
32
+ "@webex/plugin-memberships": "3.0.0-beta.15",
33
+ "@webex/plugin-messages": "3.0.0-beta.15",
34
+ "@webex/plugin-people": "3.0.0-beta.15",
35
+ "@webex/plugin-rooms": "3.0.0-beta.15",
36
+ "@webex/webex-core": "3.0.0-beta.15",
37
37
  "debug": "^4.3.4",
38
38
  "lodash": "^4.17.21"
39
39
  }
package/src/rooms.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  buildHydraRoomId,
12
12
  getHydraClusterString,
13
13
  getHydraRoomType,
14
- deconstructHydraId
14
+ deconstructHydraId,
15
15
  } from '@webex/common';
16
16
 
17
17
  const debug = require('debug')('rooms');
@@ -65,16 +65,15 @@ const Rooms = WebexPlugin.extend({
65
65
  * webex.rooms.off('updated');
66
66
  */
67
67
  listen() {
68
- return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ROOMS)
69
- .then((envelope) => {
70
- this.eventEnvelope = envelope;
71
-
72
- return this.webex.internal.mercury.connect().then(() => {
73
- this.listenTo(this.webex.internal.mercury,
74
- SDK_EVENT.INTERNAL.WEBEX_ACTIVITY,
75
- (event) => this.onWebexApiEvent(event));
76
- });
68
+ return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ROOMS).then((envelope) => {
69
+ this.eventEnvelope = envelope;
70
+
71
+ return this.webex.internal.mercury.connect().then(() => {
72
+ this.listenTo(this.webex.internal.mercury, SDK_EVENT.INTERNAL.WEBEX_ACTIVITY, (event) =>
73
+ this.onWebexApiEvent(event)
74
+ );
77
75
  });
76
+ });
78
77
  },
79
78
 
80
79
  /**
@@ -102,9 +101,8 @@ const Rooms = WebexPlugin.extend({
102
101
  method: 'POST',
103
102
  service: 'hydra',
104
103
  resource: 'rooms',
105
- body: room
106
- })
107
- .then((res) => res.body);
104
+ body: room,
105
+ }).then((res) => res.body);
108
106
  },
109
107
 
110
108
  /**
@@ -134,9 +132,8 @@ const Rooms = WebexPlugin.extend({
134
132
  return this.request({
135
133
  service: 'hydra',
136
134
  resource: `rooms/${id}`,
137
- qs: options
138
- })
139
- .then((res) => res.body.items || res.body);
135
+ qs: options,
136
+ }).then((res) => res.body.items || res.body);
140
137
  },
141
138
 
142
139
  /**
@@ -175,9 +172,8 @@ const Rooms = WebexPlugin.extend({
175
172
  return this.request({
176
173
  service: 'hydra',
177
174
  resource: 'rooms/',
178
- qs: options
179
- })
180
- .then((res) => new Page(res, this.webex));
175
+ qs: options,
176
+ }).then((res) => new Page(res, this.webex));
181
177
  },
182
178
 
183
179
  /**
@@ -230,19 +226,23 @@ const Rooms = WebexPlugin.extend({
230
226
  activitiesLimit: 0,
231
227
  computeTitleIfEmpty: true,
232
228
  conversationsLimit: 1000,
233
- isActive: true
229
+ isActive: true,
234
230
  };
235
231
 
236
232
  if (maxRecent > 0) {
237
233
  options.conversationsLimit = maxRecent;
238
234
  options.sinceDate = now.setDate(now.getDate() - 14);
239
- }
240
- else if ((maxRecent < 0) || (maxRecent > 100)) {
241
- return Promise.reject(new Error('rooms.listWithReadStatus: ' +
242
- 'optional maxRecent parameter must be an integer between 1 and 100'));
235
+ } else if (maxRecent < 0 || maxRecent > 100) {
236
+ return Promise.reject(
237
+ new Error(
238
+ 'rooms.listWithReadStatus: ' +
239
+ 'optional maxRecent parameter must be an integer between 1 and 100'
240
+ )
241
+ );
243
242
  }
244
243
 
245
- return this.webex.internal.services.waitForCatalog('postauth')
244
+ return this.webex.internal.services
245
+ .waitForCatalog('postauth')
246
246
  .then(() => this.webex.internal.conversation.list(options))
247
247
  .then((conversations) => buildRoomInfoList(this.webex, conversations));
248
248
  },
@@ -283,16 +283,17 @@ const Rooms = WebexPlugin.extend({
283
283
  const deconstructedId = deconstructHydraId(roomId);
284
284
  const conversation = {
285
285
  id: deconstructedId.id,
286
- cluster: deconstructedId.cluster
286
+ cluster: deconstructedId.cluster,
287
287
  };
288
288
 
289
- return this.webex.internal.services.waitForCatalog('postauth')
290
- .then(() => this.webex.internal.conversation.get(conversation,
291
- {
289
+ return this.webex.internal.services.waitForCatalog('postauth').then(() =>
290
+ this.webex.internal.conversation
291
+ .get(conversation, {
292
292
  computeTitleIfEmpty: true,
293
- activitiesLimit: 0 // don't send the whole history of activity
293
+ activitiesLimit: 0, // don't send the whole history of activity
294
294
  })
295
- .then((convo) => buildRoomInfo(this.webex, convo)));
295
+ .then((convo) => buildRoomInfo(this.webex, convo))
296
+ );
296
297
  },
297
298
 
298
299
  /**
@@ -328,17 +329,16 @@ const Rooms = WebexPlugin.extend({
328
329
  return this.request({
329
330
  method: 'DELETE',
330
331
  service: 'hydra',
331
- resource: `rooms/${id}`
332
- })
333
- .then((res) => {
334
- // Firefox has some issues with 204s and/or DELETE. This should move to
335
- // http-core
336
- if (res.statusCode === 204) {
337
- return undefined;
338
- }
332
+ resource: `rooms/${id}`,
333
+ }).then((res) => {
334
+ // Firefox has some issues with 204s and/or DELETE. This should move to
335
+ // http-core
336
+ if (res.statusCode === 204) {
337
+ return undefined;
338
+ }
339
339
 
340
- return res.body;
341
- });
340
+ return res.body;
341
+ });
342
342
  },
343
343
 
344
344
  /**
@@ -372,9 +372,8 @@ const Rooms = WebexPlugin.extend({
372
372
  method: 'PUT',
373
373
  service: 'hydra',
374
374
  resource: `rooms/${id}`,
375
- body: room
376
- })
377
- .then((res) => res.body);
375
+ body: room,
376
+ }).then((res) => res.body);
378
377
  },
379
378
 
380
379
  /**
@@ -392,8 +391,11 @@ const Rooms = WebexPlugin.extend({
392
391
  /* eslint-disable no-case-declarations */
393
392
  switch (activity.verb) {
394
393
  case SDK_EVENT.INTERNAL.ACTIVITY_VERB.CREATE:
395
- const roomCreatedEvent =
396
- this.getRoomEvent(this.webex, activity, SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED);
394
+ const roomCreatedEvent = this.getRoomEvent(
395
+ this.webex,
396
+ activity,
397
+ SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED
398
+ );
397
399
 
398
400
  if (roomCreatedEvent) {
399
401
  debug(`room "created" payload: \
@@ -406,8 +408,11 @@ const Rooms = WebexPlugin.extend({
406
408
  case SDK_EVENT.INTERNAL.ACTIVITY_VERB.LOCK:
407
409
  case SDK_EVENT.INTERNAL.ACTIVITY_VERB.UNLOCK:
408
410
  debug(`generating a rooms:updated based on ${activity.verb} activity`);
409
- const roomUpdatedEvent =
410
- this.getRoomEvent(this.webex, activity, SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED);
411
+ const roomUpdatedEvent = this.getRoomEvent(
412
+ this.webex,
413
+ activity,
414
+ SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED
415
+ );
411
416
 
412
417
  if (roomUpdatedEvent) {
413
418
  debug(`room "updated" payload: \
@@ -443,16 +448,14 @@ const Rooms = WebexPlugin.extend({
443
448
  sdkEvent.actorId = buildHydraPersonId(activity.actor.entryUUID, cluster);
444
449
  if (activity.object.id) {
445
450
  sdkEvent.data.id = buildHydraRoomId(activity.object.id, cluster);
446
- }
447
- else {
451
+ } else {
448
452
  sdkEvent.data.id = buildHydraRoomId(activity.target.id, cluster);
449
453
  }
450
454
 
451
455
  if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED) {
452
456
  sdkEvent.data.creatorId = buildHydraPersonId(activity.actor.entryUUID, cluster);
453
457
  sdkEvent.data.lastActivity = activity.published;
454
- }
455
- else if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED) {
458
+ } else if (event === SDK_EVENT.EXTERNAL.EVENT_TYPE.UPDATED) {
456
459
  if (activity.verb === 'update') {
457
460
  // For some reason the tags are not in the object for an update activity
458
461
  tags = activity.target.tags;
@@ -466,23 +469,21 @@ const Rooms = WebexPlugin.extend({
466
469
  // in the activity.target object. See: hydra/HydraRoom.java#L51
467
470
  // This elements seems to be missing from the activity that the SDK is getting
468
471
  // sdkEvent.data.lastActivity = activity.target.lastReadableActivityDate;
469
- }
470
- else {
472
+ } else {
471
473
  throw new Error('unexpected event type');
472
474
  }
473
475
  sdkEvent.data.type = getHydraRoomType(tags);
474
- sdkEvent.data.isLocked =
475
- tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.LOCKED);
476
+ sdkEvent.data.isLocked = tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.LOCKED);
476
477
 
477
478
  return sdkEvent;
478
- }
479
- catch (e) {
480
- this.webex.logger.error(`Unable to generate SDK event from mercury socket activity for rooms:${event} event: ${e.message}`);
479
+ } catch (e) {
480
+ this.webex.logger.error(
481
+ `Unable to generate SDK event from mercury socket activity for rooms:${event} event: ${e.message}`
482
+ );
481
483
 
482
484
  return null;
483
485
  }
484
- }
485
-
486
+ },
486
487
  });
487
488
 
488
489
  export default Rooms;
@@ -497,26 +498,24 @@ async function buildRoomInfo(webex, conversation) {
497
498
  try {
498
499
  const type = getHydraRoomType(conversation.tags);
499
500
  const cluster = getHydraClusterString(webex, conversation.url);
500
- const title = conversation.displayName ?
501
- conversation.displayName : conversation.computedTitle;
502
- const lastActivityDate = conversation.lastReadableActivityDate ?
503
- conversation.lastReadableActivityDate :
504
- conversation.lastRelevantActivityDate;
501
+ const title = conversation.displayName ? conversation.displayName : conversation.computedTitle;
502
+ const lastActivityDate = conversation.lastReadableActivityDate
503
+ ? conversation.lastReadableActivityDate
504
+ : conversation.lastRelevantActivityDate;
505
505
 
506
506
  const roomInfo = {
507
507
  id: buildHydraRoomId(conversation.id, cluster),
508
508
  type,
509
509
  ...(title && {title: conversation.displayName}),
510
510
  ...(lastActivityDate && {lastActivityDate}),
511
- lastSeenActivityDate: conversation.lastSeenActivityDate ?
512
- conversation.lastSeenActivityDate :
513
- // If user has never been seen set the date to "a long time ago"
514
- new Date(0).toISOString()
511
+ lastSeenActivityDate: conversation.lastSeenActivityDate
512
+ ? conversation.lastSeenActivityDate
513
+ : // If user has never been seen set the date to "a long time ago"
514
+ new Date(0).toISOString(),
515
515
  };
516
516
 
517
517
  return Promise.resolve(roomInfo);
518
- }
519
- catch (e) {
518
+ } catch (e) {
520
519
  return Promise.reject(e);
521
520
  }
522
521
  }
@@ -536,11 +535,10 @@ async function buildRoomInfoList(webex, conversations) {
536
535
  roomInfoPromises.push(buildRoomInfo(webex, conversation));
537
536
  }
538
537
 
539
- return Promise.all(roomInfoPromises)
540
- .then((roomInfoList) => {
541
- roomReadInfo.items = roomInfoList;
542
- roomReadInfo.items.sort((a, b) => (a.lastActivityDate < b.lastActivityDate ? 1 : -1));
538
+ return Promise.all(roomInfoPromises).then((roomInfoList) => {
539
+ roomReadInfo.items = roomInfoList;
540
+ roomReadInfo.items.sort((a, b) => (a.lastActivityDate < b.lastActivityDate ? 1 : -1));
543
541
 
544
- return roomReadInfo;
545
- });
542
+ return roomReadInfo;
543
+ });
546
544
  }
@@ -8,11 +8,7 @@ import '@webex/plugin-rooms';
8
8
  import '@webex/plugin-memberships';
9
9
  import '@webex/plugin-messages';
10
10
  import WebexCore, {WebexHttpError} from '@webex/webex-core';
11
- import {
12
- SDK_EVENT,
13
- hydraTypes,
14
- constructHydraId
15
- } from '@webex/common';
11
+ import {SDK_EVENT, hydraTypes, constructHydraId} from '@webex/common';
16
12
  import {assert} from '@webex/test-helper-chai';
17
13
  import sinon from 'sinon';
18
14
  import testUsers from '@webex/test-helper-test-users';
@@ -24,21 +20,21 @@ describe('plugin-rooms', function () {
24
20
 
25
21
  let webex, actor;
26
22
 
27
- before(() => testUsers.create({count: 1})
28
- .then(async ([user]) => {
23
+ before(() =>
24
+ testUsers.create({count: 1}).then(async ([user]) => {
29
25
  // Pause for 5 seconds for CI
30
26
  await new Promise((done) => setTimeout(done, 5000));
31
27
 
32
28
  webex = new WebexCore({credentials: user.token});
33
29
 
34
- return webex.people.get('me')
35
- .then((person) => {
36
- actor = person;
37
- debug('SDK User (Actor) for tests:');
38
- debug(`- name: ${actor.displayName}`);
39
- debug(`- id: ${actor.id}`);
40
- });
41
- }));
30
+ return webex.people.get('me').then((person) => {
31
+ actor = person;
32
+ debug('SDK User (Actor) for tests:');
33
+ debug(`- name: ${actor.displayName}`);
34
+ debug(`- id: ${actor.id}`);
35
+ });
36
+ })
37
+ );
42
38
 
43
39
  describe('#rooms', () => {
44
40
  const rooms = [];
@@ -48,15 +44,17 @@ describe('plugin-rooms', function () {
48
44
  webex.rooms.off('created');
49
45
  webex.rooms.off('updated');
50
46
 
51
- return Promise.all(rooms.map((room) => webex.rooms.remove(room)
52
- .catch((reason) => {
53
- console.error('Failed to delete room', reason);
54
- })))
55
- .then(() => {
56
- while (rooms.length) {
57
- rooms.pop();
58
- }
59
- });
47
+ return Promise.all(
48
+ rooms.map((room) =>
49
+ webex.rooms.remove(room).catch((reason) => {
50
+ console.error('Failed to delete room', reason);
51
+ })
52
+ )
53
+ ).then(() => {
54
+ while (rooms.length) {
55
+ rooms.pop();
56
+ }
57
+ });
60
58
  });
61
59
 
62
60
  describe('#create()', () => {
@@ -68,23 +66,23 @@ describe('plugin-rooms', function () {
68
66
  });
69
67
  });
70
68
 
71
- return webex.rooms.listen()
72
- .then(() => webex.rooms.create({title: 'Webex Test Room'})
73
- .then(async (room) => {
74
- assert.isRoom(room);
75
- rooms.push(room); // for future cleanup
76
- const event = await createdEventPromise;
69
+ return webex.rooms.listen().then(() =>
70
+ webex.rooms.create({title: 'Webex Test Room'}).then(async (room) => {
71
+ assert.isRoom(room);
72
+ rooms.push(room); // for future cleanup
73
+ const event = await createdEventPromise;
77
74
 
78
- validateRoomEvent(event, room, actor);
79
- }));
75
+ validateRoomEvent(event, room, actor);
76
+ })
77
+ );
80
78
  });
81
79
  });
82
80
 
83
81
  describe('#one-on-one()', () => {
84
82
  let user1, room;
85
83
 
86
- before(() => testUsers.create({count: 1})
87
- .then(async (users) => {
84
+ before(() =>
85
+ testUsers.create({count: 1}).then(async (users) => {
88
86
  // Pause for 5 seconds for CI
89
87
  await new Promise((done) => setTimeout(done, 5000));
90
88
 
@@ -92,7 +90,8 @@ describe('plugin-rooms', function () {
92
90
  debug('Test User for One-on-One room:');
93
91
  debug(`- name: ${user1.displayName}`);
94
92
  debug(`- id: ${constructHydraId(hydraTypes.PEOPLE, user1.id)}`);
95
- }));
93
+ })
94
+ );
96
95
 
97
96
  // We need a one-on-on space for this test
98
97
  // We create it by sending a message to the test user
@@ -105,11 +104,12 @@ describe('plugin-rooms', function () {
105
104
  });
106
105
  });
107
106
 
108
- return webex.rooms.listen()
109
- .then(() => webex.messages.create({
110
- toPersonId: user1.id,
111
- text: 'Message to start a one-on-on space'
112
- })
107
+ return webex.rooms.listen().then(() =>
108
+ webex.messages
109
+ .create({
110
+ toPersonId: user1.id,
111
+ text: 'Message to start a one-on-on space',
112
+ })
113
113
  .then((message) => {
114
114
  assert.exists(message.roomId);
115
115
 
@@ -121,27 +121,28 @@ describe('plugin-rooms', function () {
121
121
  const event = await createdEventPromise;
122
122
 
123
123
  validateRoomEvent(event, room, actor);
124
- }));
124
+ })
125
+ );
125
126
  });
126
127
  });
127
128
 
128
129
  describe('#get()', () => {
129
130
  let room0;
130
131
 
131
- beforeEach(() => Promise.all([
132
- webex.rooms.create({title: 'Webex Test Room 1'})
133
- .then((room) => {
132
+ beforeEach(() =>
133
+ Promise.all([
134
+ webex.rooms.create({title: 'Webex Test Room 1'}).then((room) => {
134
135
  rooms.push(room);
135
136
  }),
136
- webex.rooms.create({title: 'Webex Test Room 0'})
137
- .then((room) => {
137
+ webex.rooms.create({title: 'Webex Test Room 0'}).then((room) => {
138
138
  rooms.push(room);
139
139
  room0 = room;
140
- })
141
- ]));
140
+ }),
141
+ ])
142
+ );
142
143
 
143
- it('retrieves a specific room', () => webex.rooms.get(room0)
144
- .then((room) => {
144
+ it('retrieves a specific room', () =>
145
+ webex.rooms.get(room0).then((room) => {
145
146
  assert.isRoom(room);
146
147
 
147
148
  assert.equal(room.id, room0.id);
@@ -154,33 +155,36 @@ describe('plugin-rooms', function () {
154
155
  // the tests rely on ordering.
155
156
  let room0, room1;
156
157
 
157
- beforeEach(() => webex.rooms.create({title: 'Webex Test Room 1'})
158
- .then((room) => {
158
+ beforeEach(() =>
159
+ webex.rooms.create({title: 'Webex Test Room 1'}).then((room) => {
159
160
  rooms.push(room);
160
161
  room1 = room;
161
- }));
162
+ })
163
+ );
162
164
 
163
- beforeEach(() => webex.rooms.create({title: 'Webex Test Room 0'})
164
- .then((room) => {
165
+ beforeEach(() =>
166
+ webex.rooms.create({title: 'Webex Test Room 0'}).then((room) => {
165
167
  rooms.push(room);
166
168
  room0 = room;
167
- }));
169
+ })
170
+ );
168
171
 
169
- it('retrieves all the rooms to which I have access', () => webex.rooms.list()
170
- .then((rooms) => {
172
+ it('retrieves all the rooms to which I have access', () =>
173
+ webex.rooms.list().then((rooms) => {
171
174
  for (const room of rooms) {
172
175
  assert.isRoom(room);
173
176
  }
174
- assert.equal(rooms.items[0].id, room0.id, 'Room 0\'s id matches');
175
- assert.equal(rooms.items[0].title, room0.title, 'Room 0\'s title matches');
176
- assert.equal(rooms.items[1].id, room1.id, 'Room 1\'s id matches');
177
- assert.equal(rooms.items[1].title, room1.title, 'Room 1\'s title matches');
177
+ assert.equal(rooms.items[0].id, room0.id, "Room 0's id matches");
178
+ assert.equal(rooms.items[0].title, room0.title, "Room 0's title matches");
179
+ assert.equal(rooms.items[1].id, room1.id, "Room 1's id matches");
180
+ assert.equal(rooms.items[1].title, room1.title, "Room 1's title matches");
178
181
  }));
179
182
 
180
183
  it('retrieves a bounded, pageable set of rooms to which I have access', () => {
181
184
  const spy = sinon.spy();
182
185
 
183
- return webex.rooms.list({max: 1})
186
+ return webex.rooms
187
+ .list({max: 1})
184
188
  .then((rooms) => {
185
189
  assert.lengthOf(rooms, 1);
186
190
 
@@ -194,7 +198,7 @@ describe('plugin-rooms', function () {
194
198
  }
195
199
 
196
200
  return Promise.resolve();
197
- }(rooms));
201
+ })(rooms);
198
202
  })
199
203
  .then(() => {
200
204
  assert.isAbove(spy.callCount, 1);
@@ -207,46 +211,56 @@ describe('plugin-rooms', function () {
207
211
  describe('#getWithReadStatus()', () => {
208
212
  let room1, user2;
209
213
 
210
- before(() => testUsers.create({count: 1})
211
- .then(async ([user]) => {
214
+ before(() =>
215
+ testUsers.create({count: 1}).then(async ([user]) => {
212
216
  // Pause for 5 seconds for CI
213
217
  await new Promise((done) => setTimeout(done, 5000));
214
218
 
215
219
  user2 = user;
216
220
  user2.webex = new WebexCore({credentials: user2.token});
217
- }));
221
+ })
222
+ );
218
223
 
219
224
  // Create a space with one user who is "caught up" and another "behind"
220
- beforeEach(() => webex.rooms.create({title: 'Space to get Read Status from'})
221
- .then((room) => {
222
- rooms.push(room);
223
- room1 = room;
225
+ beforeEach(() =>
226
+ webex.rooms
227
+ .create({title: 'Space to get Read Status from'})
228
+ .then((room) => {
229
+ rooms.push(room);
230
+ room1 = room;
224
231
 
225
- return webex.memberships.create({
226
- roomId: room1.id,
227
- personId: user2.id
228
- });
229
- })
230
- // User 1 will post a message, that user2 won't have seen
231
- .then(() => webex.messages.create({
232
- roomId: room1.id,
233
- text: 'First message in room 1 from User 1'
234
- })));
235
-
236
- it('gets the read status for new room for user1', () => webex.rooms.getWithReadStatus(room1.id)
237
- .then((roomInfo) => {
238
- assert.equal(roomInfo.id, room1.id, 'Room 1\'s title matches');
239
- assert.equal(roomInfo.title, room1.title, 'Room 1\'s title matches');
240
- assert.isTrue(roomInfo.lastSeenActivityDate >= roomInfo.lastActivityDate,
241
- 'Room 1 is read for User 1');
232
+ return webex.memberships.create({
233
+ roomId: room1.id,
234
+ personId: user2.id,
235
+ });
236
+ })
237
+ // User 1 will post a message, that user2 won't have seen
238
+ .then(() =>
239
+ webex.messages.create({
240
+ roomId: room1.id,
241
+ text: 'First message in room 1 from User 1',
242
+ })
243
+ )
244
+ );
245
+
246
+ it('gets the read status for new room for user1', () =>
247
+ webex.rooms.getWithReadStatus(room1.id).then((roomInfo) => {
248
+ assert.equal(roomInfo.id, room1.id, "Room 1's title matches");
249
+ assert.equal(roomInfo.title, room1.title, "Room 1's title matches");
250
+ assert.isTrue(
251
+ roomInfo.lastSeenActivityDate >= roomInfo.lastActivityDate,
252
+ 'Room 1 is read for User 1'
253
+ );
242
254
  }));
243
255
 
244
- it('gets the read status for a new room for user2', () => user2.webex.rooms.getWithReadStatus(room1.id)
245
- .then((roomInfo) => {
246
- assert.equal(roomInfo.id, room1.id, 'Room 1\'s title matches');
247
- assert.equal(roomInfo.title, room1.title, 'Room 1\'s title matches');
248
- assert.isTrue(roomInfo.lastSeenActivityDate < roomInfo.lastActivityDate,
249
- 'Room 1 is unread for User 2');
256
+ it('gets the read status for a new room for user2', () =>
257
+ user2.webex.rooms.getWithReadStatus(room1.id).then((roomInfo) => {
258
+ assert.equal(roomInfo.id, room1.id, "Room 1's title matches");
259
+ assert.equal(roomInfo.title, room1.title, "Room 1's title matches");
260
+ assert.isTrue(
261
+ roomInfo.lastSeenActivityDate < roomInfo.lastActivityDate,
262
+ 'Room 1 is unread for User 2'
263
+ );
250
264
  }));
251
265
  });
252
266
 
@@ -255,83 +269,100 @@ describe('plugin-rooms', function () {
255
269
  // the tests rely on ordering.
256
270
  let room1, room2, user2;
257
271
 
258
- before(() => testUsers.create({count: 1})
259
- .then(async ([user]) => {
272
+ before(() =>
273
+ testUsers.create({count: 1}).then(async ([user]) => {
260
274
  // Pause for 5 seconds for CI
261
275
  await new Promise((done) => setTimeout(done, 5000));
262
276
 
263
277
  user2 = user;
264
278
  user2.webex = new WebexCore({credentials: user2.token});
265
- }));
279
+ })
280
+ );
266
281
 
267
282
  // Create two spaces with a message from each user in one of them
268
- beforeEach(() => webex.rooms.create({title: 'Unread Message for User 2'})
269
- .then((room) => {
270
- rooms.push(room);
271
- room1 = room;
283
+ beforeEach(() =>
284
+ webex.rooms
285
+ .create({title: 'Unread Message for User 2'})
286
+ .then((room) => {
287
+ rooms.push(room);
288
+ room1 = room;
272
289
 
273
- return webex.memberships.create({
274
- roomId: room1.id,
275
- personId: user2.id
276
- });
277
- })
278
- // User 1 will post a message, that user2 won't have seen
279
- .then(() => webex.messages.create({
280
- roomId: room1.id,
281
- text: 'First message in room 1 from User 1'
282
- }))
283
- // Now create the second space with the two members
284
- .then(() => webex.rooms.create({title: 'Unread Message for User 1'}))
285
- .then((room) => {
286
- rooms.push(room);
287
- room2 = room;
288
- })
289
- .then(() => webex.memberships.create({
290
- roomId: room2.id,
291
- personId: user2.id
292
- }))
293
- // User 2 will post a message, that User 1 won't have seen
294
- .then(() => user2.webex.messages.create({
295
- roomId: room2.id,
296
- text: 'First message in room 2 from User 2'
297
- })));
298
-
299
- it('gets the read status for all rooms User 1 is in', () => webex.rooms.listWithReadStatus()
300
- .then((roomList) => {
301
- assert.isArray(roomList.items,
302
- 'Expect a list or rooms from listWithReadStatus()');
303
- assert.isAbove(roomList.items.length, 1,
304
- 'Expected two or more rooms from listWithReadStatus()');
290
+ return webex.memberships.create({
291
+ roomId: room1.id,
292
+ personId: user2.id,
293
+ });
294
+ })
295
+ // User 1 will post a message, that user2 won't have seen
296
+ .then(() =>
297
+ webex.messages.create({
298
+ roomId: room1.id,
299
+ text: 'First message in room 1 from User 1',
300
+ })
301
+ )
302
+ // Now create the second space with the two members
303
+ .then(() => webex.rooms.create({title: 'Unread Message for User 1'}))
304
+ .then((room) => {
305
+ rooms.push(room);
306
+ room2 = room;
307
+ })
308
+ .then(() =>
309
+ webex.memberships.create({
310
+ roomId: room2.id,
311
+ personId: user2.id,
312
+ })
313
+ )
314
+ // User 2 will post a message, that User 1 won't have seen
315
+ .then(() =>
316
+ user2.webex.messages.create({
317
+ roomId: room2.id,
318
+ text: 'First message in room 2 from User 2',
319
+ })
320
+ )
321
+ );
322
+
323
+ it('gets the read status for all rooms User 1 is in', () =>
324
+ webex.rooms.listWithReadStatus().then((roomList) => {
325
+ assert.isArray(roomList.items, 'Expect a list or rooms from listWithReadStatus()');
326
+ assert.isAbove(
327
+ roomList.items.length,
328
+ 1,
329
+ 'Expected two or more rooms from listWithReadStatus()'
330
+ );
305
331
  for (const room of roomList.items) {
306
332
  if (room.id === room1.id) {
307
- assert.equal(room.title, room1.title, 'Room 1\'s title matches');
308
- assert.isTrue(room.lastSeenActivityDate >= room.lastActivityDate,
309
- 'Room 1 is read for User 1');
333
+ assert.equal(room.title, room1.title, "Room 1's title matches");
334
+ assert.isTrue(
335
+ room.lastSeenActivityDate >= room.lastActivityDate,
336
+ 'Room 1 is read for User 1'
337
+ );
310
338
  }
311
339
  if (room.id === room2.id) {
312
- assert.equal(room.title, room2.title, 'Room 2\'s title matches');
313
- assert.isTrue(room.lastSeenActivityDate < room.lastActivityDate,
314
- 'Room 2 is unread for User 1');
340
+ assert.equal(room.title, room2.title, "Room 2's title matches");
341
+ assert.isTrue(
342
+ room.lastSeenActivityDate < room.lastActivityDate,
343
+ 'Room 2 is unread for User 1'
344
+ );
315
345
  }
316
346
  }
317
347
  }));
318
348
 
319
- it('gets the read status for all rooms User 2 is in', () => user2.webex.rooms.listWithReadStatus()
320
- .then((roomList) => {
321
- assert.isArray(roomList.items,
322
- 'Expect a list or rooms from listWithReadStatus()');
323
- assert.equal(roomList.items.length, 2,
324
- 'Expected two rooms from listWithReadStatus()');
349
+ it('gets the read status for all rooms User 2 is in', () =>
350
+ user2.webex.rooms.listWithReadStatus().then((roomList) => {
351
+ assert.isArray(roomList.items, 'Expect a list or rooms from listWithReadStatus()');
352
+ assert.equal(roomList.items.length, 2, 'Expected two rooms from listWithReadStatus()');
325
353
  for (const room of roomList.items) {
326
354
  if (room.id === room1.id) {
327
- assert.equal(room.title, room1.title, 'Room 1\'s title matches');
328
- assert.isTrue(room.lastSeenActivityDate < room.lastActivityDate,
329
- 'Room 1 is unread for User 2');
330
- }
331
- else {
332
- assert.equal(room.title, room2.title, 'Room 2\'s title matches');
333
- assert.isTrue(room.lastSeenActivityDate >= room.lastActivityDate,
334
- 'Room 2 is read for User 2');
355
+ assert.equal(room.title, room1.title, "Room 1's title matches");
356
+ assert.isTrue(
357
+ room.lastSeenActivityDate < room.lastActivityDate,
358
+ 'Room 1 is unread for User 2'
359
+ );
360
+ } else {
361
+ assert.equal(room.title, room2.title, "Room 2's title matches");
362
+ assert.isTrue(
363
+ room.lastSeenActivityDate >= room.lastActivityDate,
364
+ 'Room 2 is read for User 2'
365
+ );
335
366
  }
336
367
  }
337
368
  }));
@@ -340,14 +371,15 @@ describe('plugin-rooms', function () {
340
371
  describe('#update()', () => {
341
372
  let room;
342
373
 
343
- beforeEach(() => webex.rooms.create({title: 'Webex Test Room'})
344
- .then((r) => {
374
+ beforeEach(() =>
375
+ webex.rooms.create({title: 'Webex Test Room'}).then((r) => {
345
376
  room = r;
346
377
  rooms.push(room);
347
378
  assert.property(room, 'id');
348
- }));
379
+ })
380
+ );
349
381
 
350
- it('updates a single room\'s title and validates a room:updated event', () => {
382
+ it("updates a single room's title and validates a room:updated event", () => {
351
383
  const r = Object.assign({}, room, {title: 'Webex Test Room with New Title'});
352
384
  const updatedEventPromise = new Promise((resolve) => {
353
385
  webex.rooms.on('updated', (event) => {
@@ -356,36 +388,39 @@ describe('plugin-rooms', function () {
356
388
  });
357
389
  });
358
390
 
359
- return webex.rooms.listen()
360
- .then(() => webex.rooms.update(r)
361
- .then(async (room) => {
362
- assert.isRoom(room);
363
- assert.deepEqual(room, r);
364
- const event = await updatedEventPromise;
391
+ return webex.rooms.listen().then(() =>
392
+ webex.rooms.update(r).then(async (room) => {
393
+ assert.isRoom(room);
394
+ assert.deepEqual(room, r);
395
+ const event = await updatedEventPromise;
365
396
 
366
- validateRoomEvent(event, room, actor);
367
- }));
397
+ validateRoomEvent(event, room, actor);
398
+ })
399
+ );
368
400
  });
369
401
  });
370
402
 
371
403
  describe('#remove()', () => {
372
404
  let room;
373
405
 
374
- beforeEach(() => webex.rooms.create({title: 'Webex Test Room'})
375
- .then((r) => {
406
+ beforeEach(() =>
407
+ webex.rooms.create({title: 'Webex Test Room'}).then((r) => {
376
408
  room = r;
377
409
  assert.property(room, 'id');
378
- }));
410
+ })
411
+ );
379
412
 
380
- it('deletes a single room', () => webex.rooms.remove(room)
381
- .then((body) => {
382
- assert.notOk(body);
413
+ it('deletes a single room', () =>
414
+ webex.rooms
415
+ .remove(room)
416
+ .then((body) => {
417
+ assert.notOk(body);
383
418
 
384
- return assert.isRejected(webex.rooms.get(room));
385
- })
386
- .then((reason) => {
387
- assert.instanceOf(reason, WebexHttpError.NotFound);
388
- }));
419
+ return assert.isRejected(webex.rooms.get(room));
420
+ })
421
+ .then((reason) => {
422
+ assert.instanceOf(reason, WebexHttpError.NotFound);
423
+ }));
389
424
  });
390
425
  });
391
426
  });
@@ -398,26 +433,19 @@ describe('plugin-rooms', function () {
398
433
  * @returns {void}
399
434
  */
400
435
  function validateRoomEvent(event, room, actor) {
401
- assert.isTrue(event.resource === SDK_EVENT.EXTERNAL.RESOURCE.ROOMS,
402
- 'not a room event');
436
+ assert.isTrue(event.resource === SDK_EVENT.EXTERNAL.RESOURCE.ROOMS, 'not a room event');
403
437
  assert.isDefined(event.event, 'room event type not set');
404
438
  assert.isDefined(event.created, 'event listener created date not set');
405
- assert.equal(event.createdBy, actor.id,
406
- 'event listener createdBy not set to our actor');
407
- assert.equal(event.orgId, actor.orgId,
408
- 'event listener orgId not === to our actor\'s');
439
+ assert.equal(event.createdBy, actor.id, 'event listener createdBy not set to our actor');
440
+ assert.equal(event.orgId, actor.orgId, "event listener orgId not === to our actor's");
409
441
  assert.equal(event.ownedBy, 'creator', 'event listener not owned by creator');
410
442
  assert.equal(event.status, 'active', 'event listener status not active');
411
- assert.equal(event.actorId, actor.id,
412
- 'event actorId not equal to our actor\'s id');
443
+ assert.equal(event.actorId, actor.id, "event actorId not equal to our actor's id");
413
444
 
414
445
  // Ensure event data matches data returned from function call
415
446
  // Skip this until we figure out how conversations converts the internal test user UUID
416
- assert.equal(event.data.id, room.id,
417
- 'event/room.id not equal');
418
- assert.equal(event.data.isLocked, room.isLocked,
419
- 'event/room.isLocked not equal');
420
- assert.equal(event.data.type, room.type,
421
- 'event/room.type not equal');
447
+ assert.equal(event.data.id, room.id, 'event/room.id not equal');
448
+ assert.equal(event.data.isLocked, room.isLocked, 'event/room.isLocked not equal');
449
+ assert.equal(event.data.type, room.type, 'event/room.type not equal');
422
450
  debug(`rooms:${event.event} event validated`);
423
451
  }