From 91abaf187f1ccafe9d3cb740b09e0d2a97268951 Mon Sep 17 00:00:00 2001 From: Tyrone Tudehope Date: Mon, 7 May 2018 22:00:07 +0200 Subject: [PATCH 1/2] Update banning-users.md to include mutations to disable feature flags and archive private channels --- docs/operations/banning-users.md | 45 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/operations/banning-users.md b/docs/operations/banning-users.md index 461d29a998..6ba3bf8ecd 100644 --- a/docs/operations/banning-users.md +++ b/docs/operations/banning-users.md @@ -20,7 +20,44 @@ r.db('spectrum') bannedReason: "Reason for ban here" }) ``` -3. Remove that user as a member from all communities and channels: +3. Disable paid feature flags for communities owned by the user. +```js +.table('communities') +.filter(function (community) { + return r.db('spectrum') + .table('usersCommunities') + .getAll(ID, { index: 'userId' }) + .filter(function (userCommunity) { + return userCommunity('communityId').eq(community('id')) + .and(userCommunity('isOwner').eq(true)) + }) + .count().gt(0) +}) +.update({ + analyticsEnabled: false, + prioritySupportEnabled: false, +}) +``` + +4. Archive all private channels in communities owned by the user + +```js +.table('channels') +.filter(function (channel) { + return r.db('spectrum') + .table('usersCommunities') + .getAll(ID, { index: 'userId' }) + .filter(function (userCommunity) { + return userCommunity('communityId').eq(channel('communityId')) + .and(userCommunity('isMember').eq(true)) + }) + .count().gt(0) + .and(channel('isPrivate').eq(true)) +}) +.update({ archivedAt: new Date() }) +``` + +5. Remove that user as a member from all communities and channels: ```js // usersCommunities .table('usersCommunities') @@ -42,7 +79,7 @@ r.db('spectrum') receiveNotifications: false, }) ``` -4. Remove all notifications from threads to save worker processing: +6. Remove all notifications from threads to save worker processing: ```js // usersThreads .table('usersThreads') @@ -51,7 +88,7 @@ r.db('spectrum') receiveNotifications: false, }) ``` -5. Reset the person's notification settings so they will not get any future emails about DMs, daily digests, etc +7. Reset the person's notification settings so they will not get any future emails about DMs, daily digests, etc ```js // usersSettings .table('usersSettings') @@ -81,4 +118,4 @@ r.db('spectrum') } }) ``` -6. Done! The user now can't be messaged, searched for, or re-logged into. The banned user no longer affects community or channel member counts, and will not ever get pulled into Athena for notifications processing. \ No newline at end of file +8. Done! The user now can't be messaged, searched for, or re-logged into. The banned user no longer affects community or channel member counts, and will not ever get pulled into Athena for notifications processing. \ No newline at end of file From 21638c515f242a1fe17cd48db95c37747efc4739 Mon Sep 17 00:00:00 2001 From: Tyrone Tudehope Date: Mon, 7 May 2018 22:05:23 +0200 Subject: [PATCH 2/2] Use correct filter for private channels --- docs/operations/banning-users.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/operations/banning-users.md b/docs/operations/banning-users.md index 6ba3bf8ecd..e0cf314f57 100644 --- a/docs/operations/banning-users.md +++ b/docs/operations/banning-users.md @@ -49,7 +49,7 @@ r.db('spectrum') .getAll(ID, { index: 'userId' }) .filter(function (userCommunity) { return userCommunity('communityId').eq(channel('communityId')) - .and(userCommunity('isMember').eq(true)) + .and(userCommunity('isOwner').eq(true)) }) .count().gt(0) .and(channel('isPrivate').eq(true))