Page MenuHomePhabricator

[keyserver] Add a function for fetching the keyserver admins ID
ClosedPublic

Authored by inka on Sep 7 2022, 3:14 AM.
Tags
None
Referenced Files
F3367919: D5078.diff
Mon, Nov 25, 5:12 PM
Unknown Object (File)
Fri, Nov 22, 2:34 PM
Unknown Object (File)
Sat, Nov 9, 6:44 PM
Unknown Object (File)
Sat, Nov 9, 6:42 PM
Unknown Object (File)
Sat, Nov 9, 4:40 PM
Unknown Object (File)
Sat, Nov 9, 4:40 PM
Unknown Object (File)
Sat, Nov 9, 4:40 PM
Unknown Object (File)
Sat, Nov 9, 4:40 PM
Subscribers

Details

Summary

A function for fetching the keyserver admins ID, similarly to D4958 - assuming there is only one community and it's admin is the keyservers admin. This will be added to ENG-1707 hack.
This function is needed in message-report creator. The function from D4958 will not be used there as it would be much slower. The function from this diff will not be used where the function from D4958 is
used, because it's used on native and web so we cannot call the database there.

Test Plan

Add the following line to the textMessageCreationResponder from keyserver/src/responders/message-responders.js:

console.log(await fetchKeyserverAdminID());

And see that when a user sends a text message (if you have just one admin in your setup) ashoat users's id (256) is logged to console.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka requested review of this revision.Sep 7 2022, 3:24 AM

Change the way we decide which threads are community threads, based on threadTypeIsCommunityRoot function

tomek requested changes to this revision.Sep 13 2022, 3:00 AM
tomek added inline comments.
keyserver/src/fetchers/user-fetchers.js
274 ↗(On Diff #16587)

According to https://linear.app/comm/issue/ENG-1707/revert-fix-getting-the-keyserver-admin-info, in our hack we not only check if it is any admin role, but also check if this role has CHANGE_ROLE permission. Can we add this check also here?

280 ↗(On Diff #16587)

We can consider logging a warning if there are more rows.

This revision now requires changes to proceed.Sep 13 2022, 3:00 AM

Log a warning when multiple potential keyserver admins found, check for CHANGE_ROLE permission

tomek requested changes to this revision.Sep 13 2022, 6:49 AM

Great! Just one last comment inline

keyserver/src/fetchers/user-fetchers.js
274–275 ↗(On Diff #16619)

Unfortunately, we don't have any automated tool for formatting SQL, but we have a convention that we indent nested statements by 2 spaces and prefer adding AND at the end of the line.

Additional note: we should use a constant instead of hardcoding change_role permission.

This revision now requires changes to proceed.Sep 13 2022, 6:49 AM
keyserver/src/fetchers/user-fetchers.js
282 ↗(On Diff #16619)

Not sure if it should say "community admin" or "keyserver admin"
On one hand the function is for fetching the keyserver admin,
but on the other hand what actually happens is we find multiple community admins.
Maybe it should say something more informative, like "more than one community admin found, assuming the keyserver admin to be of lowest id"

Make code prettier

keyserver/src/fetchers/user-fetchers.js
287

Not sure if it should say "community admin" or "keyserver admin"
On one hand the function is for fetching the keyserver admin,
but on the other hand what actually happens is we find multiple community admins.
Maybe it should say something more informative, like "more than one community admin found, assuming the keyserver admin to be of lowest id"

(Repeating so it doesn't get lost)

Looks great! Adding @ashoat so that he can take a look - this solution seems to be consistent with our current https://linear.app/comm/issue/ENG-1707/revert-fix-getting-the-keyserver-admin-info.

keyserver/src/fetchers/user-fetchers.js
287

I think the current message is fine, but improving it is also a good idea. Also curious about @ashoat opinion.

About repeating stuff: there's a setting that allows displaying all the comments, not only the ones from the most recent reviosion.

This revision is now accepted and ready to land.Sep 13 2022, 9:39 AM
This revision now requires review to proceed.Sep 13 2022, 9:39 AM
ashoat added inline comments.
keyserver/src/fetchers/user-fetchers.js
287

Looks good to me! Sorry for the delay in reviewing here

This revision is now accepted and ready to land.Sep 15 2022, 6:56 PM

This will be added to ENG-1707 hack.

Thank you for calling this out!