mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-20 20:01:25 +00:00
permissions for pinGroupPost
This commit is contained in:
parent
51dbdfa113
commit
aa35ab42f2
@ -397,6 +397,26 @@ const isAllowedToGenerateGroupInviteCode = rule({
|
||||
).records[0].get('count')
|
||||
})
|
||||
|
||||
const isAllowedToPinGroupPost = rule({
|
||||
cache: 'no_cache',
|
||||
})(async (_parent, args, context: Context) => {
|
||||
if (!context.user) return false
|
||||
|
||||
return (
|
||||
(
|
||||
await context.database.query({
|
||||
query: `
|
||||
MATCH (post:Post{id: $args.id})-[:IN]->(group:Group)
|
||||
MATCH (user:User{id: $user.id})-[membership:MEMBER_OF]->(group)
|
||||
WHERE (membership.role IN ['admin', 'owner'])
|
||||
RETURN toString(count(group)) as count
|
||||
`,
|
||||
variables: { user: context.user, args },
|
||||
})
|
||||
).records[0].get('count') === '1'
|
||||
)
|
||||
})
|
||||
|
||||
// Permissions
|
||||
export default shield(
|
||||
{
|
||||
@ -485,8 +505,8 @@ export default shield(
|
||||
VerifyEmailAddress: isAuthenticated,
|
||||
pinPost: isAdmin,
|
||||
unpinPost: isAdmin,
|
||||
pinGroupPost: isAuthenticated, // TODO: permissions
|
||||
unpinGroupPost: isAuthenticated, // TODO: permissions
|
||||
pinGroupPost: isAllowedToPinGroupPost,
|
||||
unpinGroupPost: isAllowedToPinGroupPost,
|
||||
pushPost: isAdmin,
|
||||
unpushPost: isAdmin,
|
||||
UpdateDonations: isAdmin,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user