rename communityEcology → board across backend
Model, schemas, API routes, activity log, and all server handlers updated. Old ecology/ and community-ecology routes removed, new board/ routes added. Tests updated and new board-suggestions tests written (10 cases).
This commit is contained in:
parent
59d6e97787
commit
091ec58073
20 changed files with 405 additions and 80 deletions
|
|
@ -30,7 +30,7 @@ export default defineEventHandler(async (event) => {
|
|||
status: "active",
|
||||
})
|
||||
.select(
|
||||
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags communityEcology createdAt memberNumber",
|
||||
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags board createdAt memberNumber",
|
||||
)
|
||||
.lean();
|
||||
|
||||
|
|
@ -70,18 +70,18 @@ export default defineEventHandler(async (event) => {
|
|||
if (isVisible("socialLinks")) filtered.socialLinks = member.socialLinks;
|
||||
if (isVisible("craftTags")) filtered.craftTags = member.craftTags;
|
||||
|
||||
if (isVisible("communityEcology")) {
|
||||
const ecology = member.communityEcology || {};
|
||||
filtered.communityEcology = {
|
||||
topics: ecology.topics,
|
||||
offerPeerSupport: ecology.offerPeerSupport,
|
||||
availability: ecology.availability,
|
||||
details: ecology.details,
|
||||
if (isVisible("board")) {
|
||||
const board = member.board || {};
|
||||
filtered.board = {
|
||||
topics: board.topics,
|
||||
offerPeerSupport: board.offerPeerSupport,
|
||||
availability: board.availability,
|
||||
details: board.details,
|
||||
// Contact-in-place: surface the handle + personal message only when
|
||||
// the member has explicitly opted into peer support.
|
||||
...(ecology.offerPeerSupport && {
|
||||
slackHandle: ecology.slackHandle,
|
||||
personalMessage: ecology.personalMessage,
|
||||
...(board.offerPeerSupport && {
|
||||
slackHandle: board.slackHandle,
|
||||
personalMessage: board.personalMessage,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
|
|||
const andConditions = [];
|
||||
|
||||
if (peerSupport === "true") {
|
||||
dbQuery["communityEcology.offerPeerSupport"] = true;
|
||||
dbQuery["board.offerPeerSupport"] = true;
|
||||
}
|
||||
|
||||
if (search) {
|
||||
|
|
@ -56,7 +56,7 @@ export default defineEventHandler(async (event) => {
|
|||
}
|
||||
|
||||
if (connectionTag) {
|
||||
dbQuery["communityEcology.topics.tagSlug"] = connectionTag;
|
||||
dbQuery["board.topics.tagSlug"] = connectionTag;
|
||||
}
|
||||
|
||||
if (andConditions.length > 0) {
|
||||
|
|
@ -66,7 +66,7 @@ export default defineEventHandler(async (event) => {
|
|||
try {
|
||||
const members = await Member.find(dbQuery)
|
||||
.select(
|
||||
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags communityEcology createdAt",
|
||||
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags board createdAt",
|
||||
)
|
||||
.sort({ createdAt: -1 })
|
||||
.lean();
|
||||
|
|
@ -96,14 +96,14 @@ export default defineEventHandler(async (event) => {
|
|||
if (isVisible("socialLinks")) filtered.socialLinks = member.socialLinks;
|
||||
if (isVisible("craftTags")) filtered.craftTags = member.craftTags;
|
||||
|
||||
if (isVisible("communityEcology")) {
|
||||
const ecology = member.communityEcology || {};
|
||||
filtered.communityEcology = {
|
||||
topics: ecology.topics,
|
||||
offerPeerSupport: ecology.offerPeerSupport,
|
||||
availability: ecology.availability,
|
||||
...(ecology.offerPeerSupport && {
|
||||
slackHandle: ecology.slackHandle,
|
||||
if (isVisible("board")) {
|
||||
const board = member.board || {};
|
||||
filtered.board = {
|
||||
topics: board.topics,
|
||||
offerPeerSupport: board.offerPeerSupport,
|
||||
availability: board.availability,
|
||||
...(board.offerPeerSupport && {
|
||||
slackHandle: board.slackHandle,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ export default defineEventHandler(async (event) => {
|
|||
await connectDB()
|
||||
const member = await requireAuth(event)
|
||||
|
||||
const body = await validateBody(event, communityEcologyUpdateSchema)
|
||||
const body = await validateBody(event, boardUpdateSchema)
|
||||
|
||||
const updateData = {
|
||||
'communityEcology.topics': body.topics || [],
|
||||
'communityEcology.offerPeerSupport': body.offerPeerSupport || false,
|
||||
'communityEcology.availability': body.availability || '',
|
||||
'communityEcology.slackHandle': body.slackHandle || '',
|
||||
'communityEcology.personalMessage': body.personalMessage || '',
|
||||
'communityEcology.details': body.details || '',
|
||||
'board.topics': body.topics || [],
|
||||
'board.offerPeerSupport': body.offerPeerSupport || false,
|
||||
'board.availability': body.availability || '',
|
||||
'board.slackHandle': body.slackHandle || '',
|
||||
'board.personalMessage': body.personalMessage || '',
|
||||
'board.details': body.details || '',
|
||||
}
|
||||
|
||||
if (body.offerPeerSupport && body.slackHandle) {
|
||||
|
|
@ -27,12 +27,12 @@ export default defineEventHandler(async (event) => {
|
|||
updateData.slackUserId = slackUserId
|
||||
} else {
|
||||
console.warn(
|
||||
`[Community Ecology] Could not find Slack user ID for handle: ${body.slackHandle}`,
|
||||
`[Board] Could not find Slack user ID for handle: ${body.slackHandle}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Community Ecology] Error fetching Slack user ID:', error.message)
|
||||
console.error('[Board] Error fetching Slack user ID:', error.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,21 +50,21 @@ export default defineEventHandler(async (event) => {
|
|||
})
|
||||
}
|
||||
|
||||
logActivity(member._id, 'community_ecology_updated', {
|
||||
logActivity(member._id, 'board_updated', {
|
||||
topicCount: (body.topics || []).length,
|
||||
offerPeerSupport: body.offerPeerSupport || false,
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
communityEcology: updated.communityEcology,
|
||||
board: updated.board,
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.statusCode) throw error
|
||||
console.error('Community ecology update error:', error)
|
||||
console.error('Board update error:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Failed to update community ecology settings',
|
||||
statusMessage: 'Failed to update board settings',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -32,7 +32,7 @@ export default defineEventHandler(async (event) => {
|
|||
"locationPrivacy",
|
||||
"socialLinksPrivacy",
|
||||
"craftTagsPrivacy",
|
||||
"communityEcologyPrivacy",
|
||||
"boardPrivacy",
|
||||
];
|
||||
|
||||
// Build update object from validated data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue