diff --git a/CHANGELOG.md b/CHANGELOG.md index 6450de5..648ab9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,22 @@ and this project adheres to ## [Unreleased] +## 3.5.0 - 2021-02-05 + +- Changed `displayName` of `slack_user` to use `display_name` or `real_name` or + `name`, fallback to `id` only when those are undefined. + +- Changed `username` property to use value from `user.name` instead of + `user.id`. + +- Added `userId` property using value from `user.id`. + +- Added `admin` boolean property to `slack_user`, as it is a normalized property + on the `User` class entity. + +- Added normalized boolean properties `active`, `archived`, `public`, `private` + to the `slack_channel` entity. + ## 3.4.1 - 2020-11-24 - Added retries for `slack_webapi_platform_error` error codes. The Slack Client diff --git a/package.json b/package.json index 1669994..5fd2f64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jupiterone/graph-slack", - "version": "3.4.1", + "version": "3.5.0", "description": "A graph conversion tool for https://slack.com", "license": "MPL-2.0", "main": "dist/index.js", diff --git a/src/converters.ts b/src/converters.ts index 5c3b918..453e357 100644 --- a/src/converters.ts +++ b/src/converters.ts @@ -55,11 +55,19 @@ export function createUserEntity(teamId: string, user: SlackUser): Entity { // NOTE: Slack _does not_ recommend the use of `user.name` and has moved // away from the concept of "usernames" to "display names". - username: user.id, - displayName: user.id, + userId: user.id, + username: user.name, + realName: user.real_name, + displayName: + /* istanbul ignore next */ + (!!user.profile.display_name && user.profile.display_name) || + (!!user.real_name && user.real_name) || + (!!user.name && user.name) || + user.id, email: user.profile.email, bot: user.profile.is_bot === true, mfaEnabled: user.has_2fa === true, + admin: user.is_admin === true || user.is_owner === true, teamAdmin: user.is_admin === true, teamOwner: user.is_owner === true, primaryTeamOwner: user.is_primary_owner === true, @@ -106,6 +114,10 @@ export function createChannelEntity( isMember: channel.is_member === true, isPrivate: channel.is_private === true, isMpim: channel.is_mpim === true, + active: channel.is_archived !== true, + archived: channel.is_archived === true, + private: channel.is_private === true, + public: channel.is_private !== true, topic: channel.topic.value, topicCreator: channel.topic.creator, topicLastSet: channel.topic.last_set, diff --git a/src/steps/fetch-channels/__tests__/index.test.ts b/src/steps/fetch-channels/__tests__/index.test.ts index 95335b8..77fe48c 100644 --- a/src/steps/fetch-channels/__tests__/index.test.ts +++ b/src/steps/fetch-channels/__tests__/index.test.ts @@ -43,6 +43,11 @@ test('step data collection', async () => { isPrivate: expect.any(Boolean), isMpim: expect.any(Boolean), + public: expect.any(Boolean), + private: expect.any(Boolean), + active: expect.any(Boolean), + archived: expect.any(Boolean), + topic: expect.any(String), topicCreator: expect.any(String), topicLastSet: expect.any(Number), diff --git a/src/steps/fetch-users/__tests__/index.test.ts b/src/steps/fetch-users/__tests__/index.test.ts index 3724164..3c7d918 100644 --- a/src/steps/fetch-users/__tests__/index.test.ts +++ b/src/steps/fetch-users/__tests__/index.test.ts @@ -41,17 +41,19 @@ test('step data collection', async () => { teamAdmin: expect.any(Boolean), teamOwner: expect.any(Boolean), primaryTeamOwner: expect.any(Boolean), + admin: expect.any(Boolean), restricted: expect.any(Boolean), ultraRestricted: expect.any(Boolean), active: expect.any(Boolean), updatedOn: expect.any(Number), id: expect.any(String), name: expect.any(String), + userId: expect.any(String), _key: matchesSlackUserKey(), _type: SLACK_USER_TYPE, _class: [SLACK_USER_CLASS], _rawData: expect.any(Array), - displayName: entity.id, + displayName: expect.any(String), }); }, );