This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4077 from withspectrum/2.4.43
2.4.43
- Loading branch information
Showing
29 changed files
with
848 additions
and
460 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
// @flow | ||
import type { DBCommunity } from 'shared/types'; | ||
import type { GraphQLContext } from '../../'; | ||
import { DEFAULT_USER_COMMUNITY_PERMISSIONS } from '../../models/usersCommunities'; | ||
|
||
export default ( | ||
export default async ( | ||
{ id }: DBCommunity, | ||
_: any, | ||
{ user, loaders }: GraphQLContext | ||
) => { | ||
if (!id || !user) return {}; | ||
return loaders.userPermissionsInCommunity | ||
.load([user.id, id]) | ||
.then(result => (result ? result : {})); | ||
const defaultPermissions = { | ||
...DEFAULT_USER_COMMUNITY_PERMISSIONS, | ||
userId: null, | ||
communityId: null, | ||
}; | ||
|
||
if (!id || !user) return defaultPermissions; | ||
|
||
const permissions = await loaders.userPermissionsInCommunity.load([ | ||
user.id, | ||
id, | ||
]); | ||
|
||
const fallbackPermissions = { | ||
...defaultPermissions, | ||
userId: user.id, | ||
communityId: id, | ||
}; | ||
|
||
return permissions || fallbackPermissions; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
// @flow | ||
import type { GraphQLContext } from '../../'; | ||
import type { DBUser } from 'shared/types'; | ||
import { getUsersSettings } from '../../models/usersSettings'; | ||
import { | ||
getUsersSettings, | ||
createNewUsersSettings, | ||
} from '../../models/usersSettings'; | ||
import UserError from '../../utils/UserError'; | ||
|
||
export default (_: DBUser, __: any, { user }: GraphQLContext) => { | ||
export default async (_: DBUser, __: any, { user }: GraphQLContext) => { | ||
if (!user) return new UserError('You must be signed in to continue.'); | ||
return getUsersSettings(user.id); | ||
const settings = await getUsersSettings(user.id); | ||
if (settings) return settings; | ||
return await createNewUsersSettings(user.id); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.