You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/rfcs/inactive_users_cleanup.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,3 +42,54 @@ When script started:
42
42
1. It extracts from `inactive-user` list of `userId` with score range '-inf' to 'currentimestamp - ttl'.
43
43
2. Removes all user data including aliases, emails, metadata, tokens, SSO accounts, throttles and cleans all bound indicies
44
44
3. Removes processed records from `inactive-user`
45
+
46
+
### Passed keys(next `KEY.$ind` used):
47
+
1. Inactive users list key (USER_ACTIVATE constant) = `local outIndexKey`
48
+
2. Template for user data key = `local dataKeyTemplate`
49
+
3. Template for user meta data key = `local metaKeyTemplate`
50
+
4. Template for user tokens key = `local userTokenTemplate`
51
+
5.`user-audience` zset handling key name = `local kUserAudiences`
52
+
6. Key for accessing `ALIAS_TO_ID` hash = `local kAliasToId`
53
+
7. Key for accessing `USERNAME_TO_ID` hash = `local kUsernameToId`
54
+
8. Key for accessing `SSO_TO_ID` hash = `local kSSOToId`
55
+
9. Key for accessing general users index `USERS_INDEX` = `local kIndUsers`
56
+
10. Key for accessing pulic users index `USERS_PUBLIC_INDEX` = `local kIndUsersPublic`
57
+
11. Key prefix from `THROTTLE_PREFIX` constant = `local kThrottlePrefix`
58
+
59
+
### Passed arguments(next `ARG.$ind` used):
60
+
1. UserAlias field name from user data `USERs_ALIAS_FIELD`
61
+
2. UserName field name from data `USERS_USERNAME_FIELD`
62
+
3. JSON string based on `SSO_PROVIDERS`
63
+
4. JSON string based on `THROTTLE_ACTIONS`
64
+
5. Timestamp, all users created below this value will be deleted
65
+
66
+
### How it works:
67
+
#### Main
68
+
1. Decodes from JSON passed SSO_PROVIDERS, THROTTLE_ACTIONS
69
+
2. Gets UserId's from ZSET `KEY.1` where score < `ARG.6`
70
+
3. Iterates over list:
71
+
1. Forms user data key from `KEY.2` template + userId, and gets values
72
+
2. Calls `deleteUser(userid, userdata)`
73
+
4. Deletes processed userId's from ZSET `KEY.1`
74
+
75
+
76
+
#### deleteUser(id, userdata)
77
+
Logic was adopted from `actions/removeUser.js`. Maybe I'm wrong, but all data deleted here, could be created even for inactive user.
78
+
**Except TOKENS?????**
79
+
80
+
1. Gets `username` and `alias` values from `userData` using provided `ARG.2, ARG.3`
81
+
2. If alias not empty, deletes field from `ALIAS_TO_ID`(`KEY.6`) hash
82
+
3. If username not empty(sometimes this could happen(((( ), deletes from `USERNAME_TO_ID`(`KEY.7`) hash
83
+
4. Iterates over decoded `SSO_PROVIDERS` list, and uses each value for access userData[key],
84
+
this field contains json_encoded string with provider options
85
+
1. if userData[ssoprovidername] exists, decoding it's value and checking for `uid` value.
86
+
2. If `uid` set, deletes this it's value from `SSO_TO_ID`(`KEY.8`)) hash.
87
+
5. Deletes userId from `USERS_INDEX`(`KEY.9`), `USERS_PUBLIC_INDEX`(`KEY.10`) sets.
88
+
6. Gets Audience list from `USER_AUDIENCE`(`KEY.5`), decodes it from JSON, and iterates over it's values
89
+
* forms user meta `key` name from provided template `KEY.3`, userId and `audience`
90
+
* deletes meta `key`.
91
+
7. Forms user tokens key name from `KEY.4` and deletes it
92
+
8.**THROTTLE_PREFIX constant not exists in constants.js, so assuming this left for backward compat with previous version** Iterates over decoded `THROTTLE_ACTIONS` array
93
+
* forms Throttle `key` names from userId, `THROTTLE_PREFIX`(`KEY.11`)
0 commit comments