File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,4 +35,24 @@ public function onlyInternalFederation(): bool {
3535
3636 return $ enabled === 'internal ' ;
3737 }
38+
39+ #[Override]
40+ public function isPrimary (): bool {
41+ return $ this ->isGlobalScaleEnabled ()
42+ && ($ this ->config ->getSystemValueString ('gss.mode ' , 'slave ' ) === 'master '
43+ || $ this ->config ->getSystemValueString ('gss.mode ' , 'slave ' ) === 'primary ' );
44+ }
45+
46+ #[Override]
47+ public function isSecondary (): bool {
48+ return $ this ->isGlobalScaleEnabled ()
49+ && ($ this ->config ->getSystemValueString ('gss.mode ' , 'slave ' ) === 'slave '
50+ || $ this ->config ->getSystemValueString ('gss.mode ' , 'slave ' ) === 'secondary ' );
51+ }
52+
53+ #[Override]
54+ public function isPrimaryAdmin (string $ userId ): bool {
55+ return in_array ($ userId , $ this ->config ->getSystemValue ('gss.master.admin ' , []))
56+ || in_array ($ userId , $ this ->config ->getSystemValue ('gss.primary.admin ' , []));
57+ }
3858}
Original file line number Diff line number Diff line change @@ -31,4 +31,33 @@ public function isGlobalScaleEnabled(): bool;
3131 * @since 12.0.1
3232 */
3333 public function onlyInternalFederation (): bool ;
34+
35+ /**
36+ * Check if the current instance is the primary instance.
37+ *
38+ * This instance is then only used to log in the users and then redirect them
39+ * to their associated secondary instance.
40+ *
41+ * @since 34.0.3
42+ */
43+ public function isPrimary (): bool ;
44+
45+ /**
46+ * Check if the current instance is one of the secondary instance.
47+ *
48+ * These instances are the actual instance of a user and hold all their data.
49+ *
50+ * @since 34.0.3
51+ */
52+ public function isSecondary (): bool ;
53+
54+ /**
55+ * Check if the given user is one of the admin on the primary instance.
56+ *
57+ * These users won't be redirected to a secondary instance and instead will
58+ * stay on the primary instance to manage the configuration of the instance.
59+ *
60+ * @since 34.0.3
61+ */
62+ public function isPrimaryAdmin (string $ userId ): bool ;
3463}
You can’t perform that action at this time.
0 commit comments