Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide feature InviteUsers to external people #215 #359

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/customisations/TchapComponentVisibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ File copied from ComponentVisibility.ts in matrix-react-sdk v3.46.0
// Populate this class with the details of your customisations when copying it.

import { UIComponent } from "matrix-react-sdk/src/settings/UIFeature";
import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg";

/**
* Determines whether or not the active MatrixClient user should be able to use
Expand All @@ -23,8 +24,12 @@ import { UIComponent } from "matrix-react-sdk/src/settings/UIFeature";
* otherwise.
*/
function shouldShowComponent(component: UIComponent): boolean {
const userId = MatrixClientPeg.get().getUserId();
const isExternal = userId.endsWith("agent.externe.tchap.gouv.fr") || userId.endsWith("agent.e.tchap.gouv.fr");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a function "isUserExternal" in the tchap files somewhere, so that we can reuse it later (we have not started extern customisation yet, but there will be many to do)

I would also add dev env, to avoid losing time with this when testing.

I don't know if there is a backend call we can do, or a property in MatrixClientPeg we can check, to know if a user is extern ? If we don't have anything clean like that, then this is fine.

Copy link
Member

@odelcroi odelcroi Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean to add a config var to identify which are the external server? I agree it is the same problematic than #59

if (component === UIComponent.CreateSpaces) {
return false;
} else if (component === UIComponent.InviteUsers && isExternal) {
return false;
}
return true; // default to visible
}
Expand Down