Allow members to connect and manage their Facebook pages
This commit is contained in:
@@ -49,11 +49,14 @@ export function forgetPageToken(pageId: string) {
|
||||
}
|
||||
|
||||
/** Every token source for listing pages: system user (env, optional) + each Facebook login connection. */
|
||||
export async function getPageSources(): Promise<PageSource[]> {
|
||||
export async function getPageSources(user: { id: string; globalRole: string }): Promise<PageSource[]> {
|
||||
const sources: PageSource[] = [];
|
||||
const sys = systemUserSource();
|
||||
const sys = user.globalRole === "SUPERADMIN" ? systemUserSource() : null;
|
||||
if (sys) sources.push(sys);
|
||||
const connections = await prisma.metaConnection.findMany({ orderBy: { createdAt: "asc" } });
|
||||
const connections = await prisma.metaConnection.findMany({
|
||||
where: user.globalRole === "MEMBER" ? { connectedById: user.id } : undefined,
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
for (const c of connections) {
|
||||
sources.push({ connectionId: c.id, label: c.name, token: decryptToken(c.tokenCipher) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user