diff --git a/packages/frontend-2/lib/common/generated/gql/graphql.ts b/packages/frontend-2/lib/common/generated/gql/graphql.ts index 2e7a05c15..3468bbbbb 100644 --- a/packages/frontend-2/lib/common/generated/gql/graphql.ts +++ b/packages/frontend-2/lib/common/generated/gql/graphql.ts @@ -1058,6 +1058,7 @@ export type LimitedUser = { totalOwnedStreamsFavorites: Scalars['Int']['output']; verified?: Maybe; workspaceDomainPolicyCompliant?: Maybe; + workspaceRole?: Maybe; }; @@ -1114,6 +1115,15 @@ export type LimitedUserWorkspaceDomainPolicyCompliantArgs = { workspaceId?: InputMaybe; }; + +/** + * Limited user type, for showing public info about a user + * to another user + */ +export type LimitedUserWorkspaceRoleArgs = { + workspaceId?: InputMaybe; +}; + /** Workspace metadata visible to non-workspace members. */ export type LimitedWorkspace = { __typename?: 'LimitedWorkspace'; @@ -7295,6 +7305,7 @@ export type LimitedUserFieldArgs = { totalOwnedStreamsFavorites: {}, verified: {}, workspaceDomainPolicyCompliant: LimitedUserWorkspaceDomainPolicyCompliantArgs, + workspaceRole: LimitedUserWorkspaceRoleArgs, } export type LimitedWorkspaceFieldArgs = { defaultLogoIndex: {}, diff --git a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql index 37a84b4af..226b28a18 100644 --- a/packages/server/assets/workspacesCore/typedefs/workspaces.graphql +++ b/packages/server/assets/workspacesCore/typedefs/workspaces.graphql @@ -503,6 +503,7 @@ extend type Project { # case of using userSearch, and we alway expose this extend type LimitedUser { workspaceDomainPolicyCompliant(workspaceId: String): Boolean + workspaceRole(workspaceId: String): String # if workspaceId is undefined | null, just return undefined # this can be implemented by the workspaceCore resolver too, to avoid frontend component duplication } diff --git a/packages/server/modules/core/graph/generated/graphql.ts b/packages/server/modules/core/graph/generated/graphql.ts index 224150016..c6b5b2735 100644 --- a/packages/server/modules/core/graph/generated/graphql.ts +++ b/packages/server/modules/core/graph/generated/graphql.ts @@ -1080,6 +1080,7 @@ export type LimitedUser = { totalOwnedStreamsFavorites: Scalars['Int']['output']; verified?: Maybe; workspaceDomainPolicyCompliant?: Maybe; + workspaceRole?: Maybe; }; @@ -1136,6 +1137,15 @@ export type LimitedUserWorkspaceDomainPolicyCompliantArgs = { workspaceId?: InputMaybe; }; + +/** + * Limited user type, for showing public info about a user + * to another user + */ +export type LimitedUserWorkspaceRoleArgs = { + workspaceId?: InputMaybe; +}; + /** Workspace metadata visible to non-workspace members. */ export type LimitedWorkspace = { __typename?: 'LimitedWorkspace'; @@ -5775,6 +5785,7 @@ export type LimitedUserResolvers; verified?: Resolver, ParentType, ContextType>; workspaceDomainPolicyCompliant?: Resolver, ParentType, ContextType, Partial>; + workspaceRole?: Resolver, ParentType, ContextType, Partial>; __isTypeOf?: IsTypeOfResolverFn; }; diff --git a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts index 807a1944f..b2c96a2a6 100644 --- a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts +++ b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts @@ -1061,6 +1061,7 @@ export type LimitedUser = { totalOwnedStreamsFavorites: Scalars['Int']['output']; verified?: Maybe; workspaceDomainPolicyCompliant?: Maybe; + workspaceRole?: Maybe; }; @@ -1117,6 +1118,15 @@ export type LimitedUserWorkspaceDomainPolicyCompliantArgs = { workspaceId?: InputMaybe; }; + +/** + * Limited user type, for showing public info about a user + * to another user + */ +export type LimitedUserWorkspaceRoleArgs = { + workspaceId?: InputMaybe; +}; + /** Workspace metadata visible to non-workspace members. */ export type LimitedWorkspace = { __typename?: 'LimitedWorkspace'; diff --git a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts index a0ab38e23..6e461da93 100644 --- a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts +++ b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts @@ -1357,6 +1357,24 @@ export = FF_WORKSPACES_MODULE_ENABLED findEmailsByUserId: findEmailsByUserIdFactory({ db }), getWorkspaceWithDomains: getWorkspaceWithDomainsFactory({ db }) })({ workspaceId, userId }) + }, + workspaceRole: async (parent, args, context) => { + const workspaceId = args.workspaceId + if (!workspaceId) return null + + await authorizeResolver( + context.userId, + workspaceId, + Roles.Workspace.Member, + context.resourceAccessRules + ) + + const userId = parent.id + + return await getWorkspaceRoleForUserFactory({ db })({ + userId, + workspaceId + }) } }, ServerInfo: { diff --git a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts index 1c89faa5f..6c1ae8550 100644 --- a/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts +++ b/packages/server/modules/workspacesCore/graph/resolvers/workspacesCore.ts @@ -115,7 +115,8 @@ export = !FF_WORKSPACES_MODULE_ENABLED } }, LimitedUser: { - workspaceDomainPolicyCompliant: async () => null + workspaceDomainPolicyCompliant: async () => null, + workspaceRole: async () => null }, ServerInfo: { workspaces: () => ({}) diff --git a/packages/server/test/graphql/generated/graphql.ts b/packages/server/test/graphql/generated/graphql.ts index 4d3c4b2bd..cabbd586e 100644 --- a/packages/server/test/graphql/generated/graphql.ts +++ b/packages/server/test/graphql/generated/graphql.ts @@ -1062,6 +1062,7 @@ export type LimitedUser = { totalOwnedStreamsFavorites: Scalars['Int']['output']; verified?: Maybe; workspaceDomainPolicyCompliant?: Maybe; + workspaceRole?: Maybe; }; @@ -1118,6 +1119,15 @@ export type LimitedUserWorkspaceDomainPolicyCompliantArgs = { workspaceId?: InputMaybe; }; + +/** + * Limited user type, for showing public info about a user + * to another user + */ +export type LimitedUserWorkspaceRoleArgs = { + workspaceId?: InputMaybe; +}; + /** Workspace metadata visible to non-workspace members. */ export type LimitedWorkspace = { __typename?: 'LimitedWorkspace';