refactor(community): rename Community Connections → Community Ecology
Some checks failed
Test / vitest (push) Successful in 11m42s
Test / playwright (push) Failing after 9m27s
Test / visual (push) Failing after 9m53s
Test / Notify on failure (push) Successful in 2s

Simplify the feature to pure discovery (filter by topic, see matching
members, copy Slack handle). Drop the connection request/confirm flow
entirely — Connection model, 7 API endpoints, useConnections composable,
and TagInput component deleted.

- Rename communityConnections → communityEcology in schema, API, pages
- Delete legacy fields: offering, lookingFor, peerSupport
- New /ecology page, /api/ecology/suggestions, community-ecology.patch
- Nav: "Connections" → "Ecology", remove pending-count badge
- Fix auth/member.get.js missing craftTags + communityEcology
- Add community_ecology_updated activity log type
- Expose slackHandle conditionally when offerPeerSupport is true
- Add migration script at scripts/migrate-to-ecology.js (run before deploy)
This commit is contained in:
Jennie Robinson Faber 2026-04-09 09:07:15 +01:00
parent 9577929e0d
commit 0b3896d984
33 changed files with 1002 additions and 2635 deletions

View file

@ -0,0 +1,96 @@
import Member from '../../models/member.js'
import { requireAuth } from '../../utils/auth.js'
export default defineEventHandler(async (event) => {
const member = await requireAuth(event)
const memberId = member._id
const topics = member.communityEcology?.topics || []
if (!topics.length) {
return { suggestions: [] }
}
const query = getQuery(event)
const filterTag = query.tag || null
let myTopics = topics
if (filterTag) {
myTopics = myTopics.filter((t) => t.tagSlug === filterTag)
}
if (!myTopics.length) {
return { suggestions: [] }
}
const mySlugs = myTopics.map((t) => t.tagSlug)
const candidates = await Member.find({
_id: { $ne: memberId },
status: 'active',
'communityEcology.topics.tagSlug': { $in: mySlugs },
})
.select('name avatar craftTags circle communityEcology privacy')
.lean()
if (!candidates.length) {
return { suggestions: [] }
}
const myTopicMap = {}
for (const t of myTopics) {
myTopicMap[t.tagSlug] = t.state
}
const suggestions = []
for (const candidate of candidates) {
const theirTopics = candidate.communityEcology?.topics || []
const matchingTags = []
for (const theirTopic of theirTopics) {
const myState = myTopicMap[theirTopic.tagSlug]
if (!myState) continue
matchingTags.push({
tagSlug: theirTopic.tagSlug,
yourState: myState,
theirState: theirTopic.state,
})
}
if (!matchingTags.length) continue
// Privacy filter: only expose fields the candidate allows to other members
const privacy = candidate.privacy || {}
const filtered = {
_id: candidate._id,
name: candidate.name,
circle: candidate.circle,
}
const avatarPrivacy = privacy.avatar || 'public'
if (avatarPrivacy === 'public' || avatarPrivacy === 'members') {
filtered.avatar = candidate.avatar
}
const craftTagsPrivacy = privacy.craftTags || 'members'
if (craftTagsPrivacy === 'public' || craftTagsPrivacy === 'members') {
filtered.craftTags = candidate.craftTags
}
// Expose slackHandle only when the candidate has opted into peer support.
// Slack handle is the contact-in-place path — without it, there is no way
// for the current member to reach out.
if (candidate.communityEcology?.offerPeerSupport && candidate.communityEcology?.slackHandle) {
filtered.slackHandle = candidate.communityEcology.slackHandle
}
suggestions.push({
member: filtered,
matchingTags,
matchCount: matchingTags.length,
})
}
suggestions.sort((a, b) => b.matchCount - a.matchCount)
return { suggestions }
})