@webex/plugin-rooms 3.0.0-beta.9 → 3.0.0-bnr.2

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/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"],"m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QC,OAAR,CAAgBH,QAAhB,CArBX;;UAAA;YAAA;YAAA;YAAA,kCAwBW,iBAAQjE,MAAR,cAxBX;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C;;;;SAkCeM,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,EACJ3G,IADI,CACC,UAAC8G,YAAD,EAAkB;cACtBJ,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,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":";;;;;;;;;;;;;;;;;;;;;;;AAIA;AAEA;AAQuB;AAAA;AAAA;AAAA;AAAA;AAEvB,IAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,KAAK,GAAGC,sBAAW,CAACC,MAAM,CAAC;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,MAAM,oBAAG;IAAA;IACP,OAAO,IAAAC,2BAAmB,EAAC,IAAI,CAACC,KA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GAAG,CAAC,CAAC;YAAA,CAAC,CAAC;YAErF,OAAOO,YAAY;UACrB,CAAC,CAAC;QAAA;QAAA;UAAA;MAAA;IAAA;EAAA,CACH;EAAA;AAAA"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.4"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,2 @@
1
+ export default Rooms;
2
+ import Rooms from "./rooms";
@@ -0,0 +1,41 @@
1
+ export default Rooms;
2
+ export type RoomObject = {
3
+ /**
4
+ * - (server generated) Unique identifier for the room
5
+ */
6
+ id: string;
7
+ /**
8
+ * - The display name for the room. All room members
9
+ * will see the title so make it something good
10
+ */
11
+ title: string;
12
+ /**
13
+ * - (optional) The ID of the team to which the room
14
+ * belongs
15
+ */
16
+ teamId: string;
17
+ /**
18
+ * - (server generated) The date and time that the
19
+ * room was created
20
+ */
21
+ created: isoDate;
22
+ };
23
+ /**
24
+ * @typedef {Object} RoomObject
25
+ * @property {string} id - (server generated) Unique identifier for the room
26
+ * @property {string} title - The display name for the room. All room members
27
+ * will see the title so make it something good
28
+ * @property {string} teamId - (optional) The ID of the team to which the room
29
+ * belongs
30
+ * @property {isoDate} created - (server generated) The date and time that the
31
+ * room was created
32
+ */
33
+ /**
34
+ * Rooms are virtual meeting places for getting stuff done. This resource
35
+ * represents the room itself. Check out the {@link Memberships} API to learn
36
+ * how to add and remove people from rooms and the {@link Messages} API for
37
+ * posting and managing content.
38
+ * @class
39
+ * @name Rooms
40
+ */
41
+ declare const Rooms: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-rooms",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-bnr.2",
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.9",
24
- "@webex/test-helper-test-users": "3.0.0-beta.9",
23
+ "@webex/test-helper-chai": "3.0.0-bnr.2",
24
+ "@webex/test-helper-test-users": "3.0.0-bnr.2",
25
25
  "sinon": "^9.2.4"
26
26
  },
27
27
  "dependencies": {
28
- "@webex/common": "3.0.0-beta.9",
29
- "@webex/internal-plugin-conversation": "3.0.0-beta.9",
30
- "@webex/internal-plugin-mercury": "3.0.0-beta.9",
31
- "@webex/plugin-logger": "3.0.0-beta.9",
32
- "@webex/plugin-memberships": "3.0.0-beta.9",
33
- "@webex/plugin-messages": "3.0.0-beta.9",
34
- "@webex/plugin-people": "3.0.0-beta.9",
35
- "@webex/plugin-rooms": "3.0.0-beta.9",
36
- "@webex/webex-core": "3.0.0-beta.9",
28
+ "@webex/common": "3.0.0-bnr.2",
29
+ "@webex/internal-plugin-conversation": "3.0.0-bnr.2",
30
+ "@webex/internal-plugin-mercury": "3.0.0-bnr.2",
31
+ "@webex/plugin-logger": "3.0.0-bnr.2",
32
+ "@webex/plugin-memberships": "3.0.0-bnr.2",
33
+ "@webex/plugin-messages": "3.0.0-bnr.2",
34
+ "@webex/plugin-people": "3.0.0-bnr.2",
35
+ "@webex/plugin-rooms": "3.0.0-bnr.2",
36
+ "@webex/webex-core": "3.0.0-bnr.2",
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
  }