Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions backend/src/constants/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const CHAT_MESSAGE_ADDED = 'CHAT_MESSAGE_ADDED'
export const CHAT_MESSAGE_STATUS_UPDATED = 'CHAT_MESSAGE_STATUS_UPDATED'
export const ROOM_UPDATED = 'ROOM_UPDATED'
export const VIDEO_CALL_PARTICIPANT_COUNT_CHANGED = 'VIDEO_CALL_PARTICIPANT_COUNT_CHANGED'
export const GROUP_MEMBERSHIP_VISIBILITY_CHANGED = 'GROUP_MEMBERSHIP_VISIBILITY_CHANGED'
export const GROUP_SHOW_MEMBERS_CHANGED = 'GROUP_SHOW_MEMBERS_CHANGED'
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { getDriver } from '@db/neo4j'

export const description =
'Add showOnProfile field to all existing MEMBER_OF relationships, defaulting to true. Controls whether a group membership is displayed on the user profile page.'

export async function up(_next) {
const driver = getDriver()
const session = driver.session()
const transaction = session.beginTransaction()
try {
await transaction.run(
`
MATCH (user:User)-[membership:MEMBER_OF]->(group:Group)
WHERE membership.showOnProfile IS NULL
SET membership.showOnProfile = true
`,
)
await transaction.commit()
} catch (error) {
// eslint-disable-next-line no-console
console.log(error)
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
} finally {
await session.close()
}
}

export async function down(_next) {
const driver = getDriver()
const session = driver.session()
const transaction = session.beginTransaction()
try {
await transaction.run(
`
MATCH (user:User)-[membership:MEMBER_OF]->(group:Group)
REMOVE membership.showOnProfile
`,
)
await transaction.commit()
} catch (error) {
// eslint-disable-next-line no-console
console.log(error)
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
} finally {
await session.close()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { getDriver } from '@db/neo4j'

export const description =
'Add showMembers field to existing closed Group nodes, defaulting to false. Public and hidden groups ignore this field (always true / always false).'

export async function up(_next) {
const driver = getDriver()
const session = driver.session()
const transaction = session.beginTransaction()
try {
await transaction.run(
`
MATCH (group:Group)
WHERE group.groupType = 'closed' AND group.showMembers IS NULL
SET group.showMembers = false
`,
)
await transaction.commit()
} catch (error) {
// eslint-disable-next-line no-console
console.log(error)
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
} finally {
await session.close()
}
}

export async function down(_next) {
const driver = getDriver()
const session = driver.session()
const transaction = session.beginTransaction()
try {
await transaction.run(
`
MATCH (group:Group)
REMOVE group.showMembers
`,
)
await transaction.commit()
} catch (error) {
// eslint-disable-next-line no-console
console.log(error)
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
} finally {
await session.close()
}
}
426 changes: 426 additions & 0 deletions backend/src/db/seed.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/src/graphql/queries/groups/Group.gql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ query Group($isMember: Boolean, $id: ID, $slug: String) {
name
}
myRole
showMembers
membersCount
currentlyPinnedPostsCount
inviteCodes {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mutation SetGroupMembershipVisibility($groupId: ID!, $showOnProfile: Boolean!) {
setGroupMembershipVisibility(groupId: $groupId, showOnProfile: $showOnProfile) {
role
showOnProfile
}
}
2 changes: 2 additions & 0 deletions backend/src/graphql/queries/groups/UpdateGroup.gql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mutation UpdateGroup(
$categoryIds: [ID]
$avatar: ImageInput
$locationName: String # empty string '' sets it to null
$showMembers: Boolean
) {
UpdateGroup(
id: $id
Expand All @@ -21,6 +22,7 @@ mutation UpdateGroup(
categoryIds: $categoryIds
avatar: $avatar
locationName: $locationName
showMembers: $showMembers
) {
id
name
Expand Down
13 changes: 13 additions & 0 deletions backend/src/graphql/queries/groups/UserGroups.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query UserGroups($id: ID!, $first: Int, $offset: Int) {
User(id: $id) {
id
groups(first: $first, offset: $offset) {
id
name
groupType
myRole
membersCount
postsCount
}
}
}
6 changes: 6 additions & 0 deletions backend/src/graphql/queries/users/UpdateUser.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ mutation UpdateUser(
$about: String
$allowEmbedIframes: Boolean
$showShoutsPublicly: Boolean
$showPublicGroupsOnProfile: Boolean
$showClosedGroupsOnProfile: Boolean
$showHiddenGroupsOnProfile: Boolean
$emailNotificationSettings: [EmailNotificationSettingsInput]
$termsAndConditionsAgreedVersion: String
$avatar: ImageInput
Expand All @@ -18,6 +21,9 @@ mutation UpdateUser(
about: $about
allowEmbedIframes: $allowEmbedIframes
showShoutsPublicly: $showShoutsPublicly
showPublicGroupsOnProfile: $showPublicGroupsOnProfile
showClosedGroupsOnProfile: $showClosedGroupsOnProfile
showHiddenGroupsOnProfile: $showHiddenGroupsOnProfile
emailNotificationSettings: $emailNotificationSettings
termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion
avatar: $avatar
Expand Down
Loading
Loading