Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #35 from JupiterOne/displayname
Browse files Browse the repository at this point in the history
Displayname
  • Loading branch information
erkangz authored Feb 5, 2021
2 parents 965b735 + 8791520 commit 9b9930c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 14 additions & 2 deletions src/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/steps/fetch-channels/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion src/steps/fetch-users/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
},
);
Expand Down

0 comments on commit 9b9930c

Please sign in to comment.