diff --git a/keyserver/src/fetchers/link-fetchers.js b/keyserver/src/fetchers/link-fetchers.js --- a/keyserver/src/fetchers/link-fetchers.js +++ b/keyserver/src/fetchers/link-fetchers.js @@ -63,15 +63,25 @@ return []; } + let condition; + if (viewer.isScriptViewer) { + condition = SQL`WHERE i.\`primary\` = 1`; + } else { + condition = SQL` + INNER JOIN memberships m + ON i.community = m.thread AND m.user = ${viewer.userID} + WHERE i.\`primary\` = 1 AND m.role > 0 + `; + } + const query = SQL` SELECT i.name, i.role, i.community, i.expiration_time AS expirationTime, i.limit_of_uses AS limitOfUses, i.number_of_uses AS numberOfUses, i.\`primary\`, blob_holder AS blobHolder FROM invite_links i - INNER JOIN memberships m - ON i.community = m.thread AND m.user = ${viewer.userID} - WHERE i.\`primary\` = 1 AND m.role > 0 `; + query.append(condition); + const [result] = await dbQuery(query); return result.map(row => ({ name: row.name,