chore(slack): remove dead invite path, archive checkSlackJoins poller
Wave-based onboarding makes the auto-invite + polling path obsolete. - Removes SlackService.inviteUserToSlack — admins now send invites through Slack's UI and flip the flag in our admin endpoint. - Removes the slack_invite_failed admin alert + its detector. The alert no longer has a meaningful trigger (we don't attempt invites). - Archives server/utils/checkSlackJoins.js (and its test) under _archive/ in case the polling pattern is needed again post-pilot. - Deletes the Nitro plugin that scheduled checkSlackJoins on boot + hourly. Nothing in nitro.config / nuxt.config / package.json registered it elsewhere. - Drops the slack_invite_failed branch from adminAlerts.test; the enum slug stays in adminAlertDismissal so historical dismissal rows continue to validate. notifyNewMember (vetting-channel notification) and findUserByEmail (used by the auto-flag helper) are retained.
This commit is contained in:
parent
7b326f879d
commit
d15458b30a
10 changed files with 247 additions and 197 deletions
|
|
@ -1,5 +1,23 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
import {
|
||||
ALERT_THRESHOLDS,
|
||||
computeSignature,
|
||||
detectNoSlackHandleAfterWeek,
|
||||
detectStuckPendingPayment,
|
||||
detectSuspendedMembers,
|
||||
detectPreRegistrantSelectedNotInvited,
|
||||
detectPreRegistrantExpired,
|
||||
detectDraftEventsImminent,
|
||||
detectEventsNearCapacity, detectPendingTagSuggestions , computeAllAlerts
|
||||
} from '../../../server/utils/adminAlerts.js'
|
||||
import Member from '../../../server/models/member.js'
|
||||
import PreRegistration from '../../../server/models/preRegistration.js'
|
||||
import Event from '../../../server/models/event.js'
|
||||
import TagSuggestion from '../../../server/models/tagSuggestion.js'
|
||||
|
||||
import AdminAlertDismissal from '../../../server/models/adminAlertDismissal.js'
|
||||
|
||||
vi.mock('../../../server/utils/mongoose.js', () => ({
|
||||
connectDB: vi.fn()
|
||||
}))
|
||||
|
|
@ -34,7 +52,6 @@ vi.mock('../../../server/models/adminAlertDismissal.js', () => ({
|
|||
find: vi.fn()
|
||||
},
|
||||
ADMIN_ALERT_TYPES: [
|
||||
'slack_invite_failed',
|
||||
'no_slack_handle_week',
|
||||
'stuck_pending_payment',
|
||||
'member_suspended',
|
||||
|
|
@ -46,24 +63,6 @@ vi.mock('../../../server/models/adminAlertDismissal.js', () => ({
|
|||
]
|
||||
}))
|
||||
|
||||
import {
|
||||
ALERT_THRESHOLDS,
|
||||
computeSignature,
|
||||
detectSlackInviteFailed,
|
||||
detectNoSlackHandleAfterWeek,
|
||||
detectStuckPendingPayment,
|
||||
detectSuspendedMembers,
|
||||
detectPreRegistrantSelectedNotInvited,
|
||||
detectPreRegistrantExpired,
|
||||
detectDraftEventsImminent,
|
||||
detectEventsNearCapacity
|
||||
} from '../../../server/utils/adminAlerts.js'
|
||||
import Member from '../../../server/models/member.js'
|
||||
import PreRegistration from '../../../server/models/preRegistration.js'
|
||||
import Event from '../../../server/models/event.js'
|
||||
import { detectPendingTagSuggestions } from '../../../server/utils/adminAlerts.js'
|
||||
import TagSuggestion from '../../../server/models/tagSuggestion.js'
|
||||
|
||||
describe('adminAlerts module shell', () => {
|
||||
describe('ALERT_THRESHOLDS', () => {
|
||||
it('exposes the four documented thresholds', () => {
|
||||
|
|
@ -113,36 +112,6 @@ describe('adminAlerts module shell', () => {
|
|||
})
|
||||
}
|
||||
|
||||
describe('detectSlackInviteFailed', () => {
|
||||
it('returns matching members with critical severity', async () => {
|
||||
mockMemberFind([
|
||||
{ _id: 'm1', name: 'Alex', email: 'alex@example.com' },
|
||||
{ _id: 'm2', name: 'Bea', email: 'bea@example.com' }
|
||||
])
|
||||
|
||||
const alert = await detectSlackInviteFailed()
|
||||
|
||||
expect(alert.type).toBe('slack_invite_failed')
|
||||
expect(alert.severity).toBe('critical')
|
||||
expect(alert.items).toHaveLength(2)
|
||||
expect(alert.items[0]).toEqual({
|
||||
id: 'm1',
|
||||
label: 'Alex',
|
||||
sublabel: 'alex@example.com',
|
||||
href: '/admin/members/m1'
|
||||
})
|
||||
expect(Member.find).toHaveBeenCalledWith(
|
||||
{ slackInviteStatus: 'failed' }
|
||||
)
|
||||
})
|
||||
|
||||
it('returns an empty list when nothing matches', async () => {
|
||||
mockMemberFind([])
|
||||
const alert = await detectSlackInviteFailed()
|
||||
expect(alert.items).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('detectNoSlackHandleAfterWeek', () => {
|
||||
it('queries active members joined more than 7 days ago without a slackUserId', async () => {
|
||||
mockMemberFind([
|
||||
|
|
@ -392,9 +361,6 @@ describe('adminAlerts module shell', () => {
|
|||
})
|
||||
})
|
||||
|
||||
import { computeAllAlerts } from '../../../server/utils/adminAlerts.js'
|
||||
import AdminAlertDismissal from '../../../server/models/adminAlertDismissal.js'
|
||||
|
||||
describe('computeAllAlerts aggregator', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
|
|
@ -423,7 +389,7 @@ describe('computeAllAlerts aggregator', () => {
|
|||
|
||||
it('returns alerts that have items and have not been dismissed', async () => {
|
||||
Member.find.mockImplementation((query) => {
|
||||
if (query.slackInviteStatus === 'failed') {
|
||||
if (query.status === 'suspended') {
|
||||
return { select: vi.fn().mockReturnValue({ lean: vi.fn().mockResolvedValue([
|
||||
{ _id: 'm1', name: 'Alex', email: 'alex@example.com' }
|
||||
]) }) }
|
||||
|
|
@ -433,13 +399,13 @@ describe('computeAllAlerts aggregator', () => {
|
|||
|
||||
const alerts = await computeAllAlerts('admin-1')
|
||||
expect(alerts).toHaveLength(1)
|
||||
expect(alerts[0].type).toBe('slack_invite_failed')
|
||||
expect(alerts[0].type).toBe('member_suspended')
|
||||
expect(alerts[0].signature).toMatch(/^[a-f0-9]+$/)
|
||||
})
|
||||
|
||||
it('hides alerts whose signature matches an existing dismissal', async () => {
|
||||
Member.find.mockImplementation((query) => {
|
||||
if (query.slackInviteStatus === 'failed') {
|
||||
if (query.status === 'suspended') {
|
||||
return { select: vi.fn().mockReturnValue({ lean: vi.fn().mockResolvedValue([
|
||||
{ _id: 'm1', name: 'Alex', email: 'alex@example.com' }
|
||||
]) }) }
|
||||
|
|
@ -450,7 +416,7 @@ describe('computeAllAlerts aggregator', () => {
|
|||
const sig = computeSignature(['m1'])
|
||||
AdminAlertDismissal.find.mockReturnValue({
|
||||
lean: vi.fn().mockResolvedValue([
|
||||
{ adminId: 'admin-1', alertType: 'slack_invite_failed', signature: sig }
|
||||
{ adminId: 'admin-1', alertType: 'member_suspended', signature: sig }
|
||||
])
|
||||
})
|
||||
|
||||
|
|
@ -460,7 +426,7 @@ describe('computeAllAlerts aggregator', () => {
|
|||
|
||||
it('shows an alert again when the underlying set changes', async () => {
|
||||
Member.find.mockImplementation((query) => {
|
||||
if (query.slackInviteStatus === 'failed') {
|
||||
if (query.status === 'suspended') {
|
||||
return { select: vi.fn().mockReturnValue({ lean: vi.fn().mockResolvedValue([
|
||||
{ _id: 'm1', name: 'Alex', email: 'alex@example.com' },
|
||||
{ _id: 'm2', name: 'Bea', email: 'bea@example.com' }
|
||||
|
|
@ -472,7 +438,7 @@ describe('computeAllAlerts aggregator', () => {
|
|||
const staleSig = computeSignature(['m1']) // dismissal was for the old single-member state
|
||||
AdminAlertDismissal.find.mockReturnValue({
|
||||
lean: vi.fn().mockResolvedValue([
|
||||
{ adminId: 'admin-1', alertType: 'slack_invite_failed', signature: staleSig }
|
||||
{ adminId: 'admin-1', alertType: 'member_suspended', signature: staleSig }
|
||||
])
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue