diff --git a/server/src/fetchers/session-fetchers.js b/server/src/fetchers/session-fetchers.js index 5f9e94f93..32931ed41 100644 --- a/server/src/fetchers/session-fetchers.js +++ b/server/src/fetchers/session-fetchers.js @@ -1,45 +1,45 @@ // @flow import type { CalendarQuery } from 'lib/types/entry-types'; import { dbQuery, SQL } from '../database/database'; import type { Viewer } from '../session/viewer'; type CalendarSessionResult = {| userID: string, session: string, calendarQuery: CalendarQuery, |}; async function fetchActiveSessionsForThread( threadID: string, ): Promise { const query = SQL` SELECT s.id, s.user, s.query FROM memberships m LEFT JOIN sessions s ON s.user = m.user - WHERE m.thread = ${threadID} AND m.role >= 0 + WHERE m.thread = ${threadID} AND m.role > 0 AND s.query IS NOT NULL `; const [result] = await dbQuery(query); const filters = []; for (const row of result) { filters.push({ userID: row.user.toString(), session: row.id.toString(), calendarQuery: row.query, }); } return filters; } async function fetchOtherSessionsForViewer(viewer: Viewer): Promise { const query = SQL` SELECT id FROM sessions WHERE user = ${viewer.userID} AND id != ${viewer.session} `; const [result] = await dbQuery(query); return result.map((row) => row.id.toString()); } export { fetchActiveSessionsForThread, fetchOtherSessionsForViewer };