HomePhabricator
Diffusion Comm 666f3682f9e6

[lib] Replace `filterThreadEditDetailedPermissions` with…

Description

[lib] Replace filterThreadEditDetailedPermissions with filterThreadPermissions

Summary:
We were previously filtering out some permissions using filterThreadEditDetailedPermissions for older clients.

Similarly, we want to filter out edit_thread_avatar permissions for old clients. The current filterThreadEditDetailedPermissions only handles one particlar filtering.

We could just add another filterThreadEditAvatarPermission function that similarly takes (ThreadPermissionsInfo, boolean), but then things get messy at the callsite where we have to run permissions through two separate filtering functions. This might be fine for now... but it's not super extensible when we add further permissions.

We could separately create a function that handles all of the filtering and takes a bunch of boolean arguments for each set of permissions that we might want to exclude. This would also kind of get messy as every time we add a permission we'll need to change the function signature and all of the callsites.

Instead, I think the cleanest solution is to construct a filterThreadPermissions directly in rawThreadInfoFromServerThreadInfo based on the RawThreadInfoOptions that have been passed in and use that filterThreadPermissions function throughout rawThreadInfoFromServerThreadInfo. It also keeps everything "in one place," which I think makes things more extensible (next diff will extend filterThreadPermissions for filtering avatar permissions).

Test Plan:
Manually set filterDetailedThreadEditPermissions and log the filtered return value of filterThreadPermissions to ensure that things are being filtered out as expected.

Also check D7364 for more thorough testing with filterThreadEditAvatarPermission.

Reviewers: ashoat, ginsu, rohan

Reviewed By: ashoat

Subscribers: rohan, tomek

Differential Revision: https://phab.comm.dev/D7363