diff --git a/.changeset/fix-industry-alerts-channel-filter.md b/.changeset/fix-industry-alerts-channel-filter.md new file mode 100644 index 0000000000..a01b9e0e1b --- /dev/null +++ b/.changeset/fix-industry-alerts-channel-filter.md @@ -0,0 +1,7 @@ +--- +"adcontextprotocol": patch +--- + +Fix industry alerts not posting to Slack channels + +The `hasAlertedPerspective()` check was blocking articles from being posted to real Slack channels if they had already been posted to website-only channels. Removed the redundant check since the SQL query already handles per-channel deduplication correctly. diff --git a/package-lock.json b/package-lock.json index 6553fed6fa..08d3cd09ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "adcontextprotocol", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "adcontextprotocol", - "version": "2.5.1", + "version": "2.5.2", "dependencies": { "@adcp/client": "^3.5.2", "@anthropic-ai/sdk": "^0.71.2", diff --git a/server/src/addie/services/industry-alerts.ts b/server/src/addie/services/industry-alerts.ts index fb31edeede..f3478eb065 100644 --- a/server/src/addie/services/industry-alerts.ts +++ b/server/src/addie/services/industry-alerts.ts @@ -13,10 +13,7 @@ import { logger } from '../../logger.js'; import { sendChannelMessage } from '../../slack/client.js'; import type { SlackBlock } from '../../slack/types.js'; import { query } from '../../db/client.js'; -import { - recordPerspectiveAlert, - hasAlertedPerspective, -} from '../../db/industry-feeds-db.js'; +import { recordPerspectiveAlert } from '../../db/industry-feeds-db.js'; import { getActiveChannels, isWebsiteOnlyChannel, @@ -298,11 +295,6 @@ export async function processAlerts(): Promise<{ continue; } - // Skip if already alerted (race condition protection) - if (await hasAlertedPerspective(article.perspective_id)) { - continue; - } - // Verify pacing: quality 5 always posts, quality 4 only if quiet if (article.quality_score === 4 && !isQuiet) { logger.debug( diff --git a/server/src/db/industry-feeds-db.ts b/server/src/db/industry-feeds-db.ts index 19c7a06926..3af6f9f34c 100644 --- a/server/src/db/industry-feeds-db.ts +++ b/server/src/db/industry-feeds-db.ts @@ -380,17 +380,6 @@ export async function getRecentRssPerspectives( // ============== Alert Operations ============== -/** - * Check if we've already alerted for this perspective - */ -export async function hasAlertedPerspective(perspectiveId: string): Promise { - const result = await query<{ exists: boolean }>( - `SELECT EXISTS(SELECT 1 FROM industry_alerts WHERE perspective_id = $1)`, - [perspectiveId] - ); - return result.rows[0].exists; -} - /** * Record that we sent an alert for a perspective */ @@ -409,56 +398,6 @@ export async function recordPerspectiveAlert( return result.rows[0]; } -/** - * Get RSS perspectives that should be alerted - * (high quality, relevant mentions, not yet alerted) - */ -export async function getPerspectivesToAlert(): Promise<{ - id: string; - title: string; - link: string; - summary: string; - addie_notes: string; - quality_score: number; - mentions_agentic: boolean; - mentions_adcp: boolean; - relevance_tags: string[]; - feed_name: string; -}[]> { - const result = await query<{ - id: string; - title: string; - link: string; - summary: string; - addie_notes: string; - quality_score: number; - mentions_agentic: boolean; - mentions_adcp: boolean; - relevance_tags: string[]; - feed_name: string; - }>( - `SELECT p.id, p.title, p.external_url as link, - k.summary, k.addie_notes, k.quality_score, - k.mentions_agentic, k.mentions_adcp, k.relevance_tags, - f.name as feed_name - FROM perspectives p - JOIN industry_feeds f ON p.feed_id = f.id - JOIN addie_knowledge k ON k.source_url = p.external_url - WHERE p.source_type = 'rss' - AND p.status = 'published' - AND k.fetch_status = 'success' - AND NOT EXISTS (SELECT 1 FROM industry_alerts ia WHERE ia.perspective_id = p.id) - AND (k.quality_score >= 4 OR k.mentions_agentic = true OR k.mentions_adcp = true) - ORDER BY - CASE WHEN k.mentions_adcp THEN 0 - WHEN k.mentions_agentic THEN 1 - ELSE 2 END, - k.quality_score DESC NULLS LAST - LIMIT 20` - ); - return result.rows; -} - // ============== Stats ============== export interface FeedStats {