From 94e5d8df644f8a77823797c9b7ebedb5da8402ef Mon Sep 17 00:00:00 2001 From: insert Date: Fri, 18 Aug 2023 18:32:05 -0400 Subject: [PATCH] more moderation ui tweeks, renaming and description, env var for groups --- index.js | 48 +++++++++++++++++++++--------------- web/src/views/Moderation.vue | 46 +++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index d9e17b7..345245f 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ const { onShutdown } = require('node-graceful-shutdown') const ActivitypubExpress = require('activitypub-express') const { version } = require('./package.json') -const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT_HTTPS, DB_URL, DB_NAME, PROXY_MODE, ADMIN_SECRET, USE_ATTACHMENTS } = process.env +const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT_HTTPS, DB_URL, DB_NAME, PROXY_MODE, ADMIN_SECRET, USE_ATTACHMENTS, GROUPS } = process.env const app = express() const client = new MongoClient(DB_URL) @@ -196,10 +196,10 @@ app.on('apex-inbox', async ({ actor, activity, recipient, object }) => { console.log(await apex.store.db.collection(`${recipient.id}-queue`).find().toArray()) console.log(find) //idk why but this works - var find2 = await apex.store.db.collection(`keys`).findOne( {id: recipient.id} ) - if (!find2) { - await apex.store.db.collection(`keys`).insertOne(recipient) - } + //var find2 = await apex.store.db.collection(`keys`).findOne( {id: recipient.id} ) + //if (!find2) { + // await apex.store.db.collection(`keys`).insertOne(recipient) + //} //apex.addToOutbox(recipient, share) break @@ -267,16 +267,18 @@ app.get('/stats', async (req, res, next) => { } }) +app.get('/mod/userinfo', async (req, res, next) => { + try { + object = await apex.store.getObject(apex.utils.usernameToIRI(req.query.name)) + res.json(object) + } catch (err) { + next(err) + } +}) + app.get('/mod/data', async (req, res, next) => { try { - console.log(req.query) - console.log(req.query.name) - console.log(apex.utils.usernameToIRI('test')) - console.log(await apex.utils.usernameToIRI('test')) const object = await apex.store.getObject(apex.utils.usernameToIRI(req.query.name)) - console.log(object) - console.log(object.id) - console.log("test") const queueSize = await apex.store.db.collection(`${object.id}-queue`).find().toArray() // console.log(res.json({queueSize})) console.log(queueSize) @@ -289,13 +291,13 @@ app.get('/mod/data', async (req, res, next) => { app.get('/mod/approve', async (req, res, next) => { try { console.log("recived") - const object = await apex.store.getObject(apex.utils.usernameToIRI(req.query.name)) + const object = await apex.store.getObject(apex.utils.usernameToIRI(req.query.name), true) //console.log(object) //onsole.log(object.publicKey) - const keys = await apex.store.db.collection(`keys`).findOne( {id: object.id} ) + //const keys = await apex.store.db.collection(`keys`).findOne( {id: object.id} ) const dbout = await apex.store.db.collection(`${object.id}-queue`).findOne( {object: [req.query.id]} ) - console.log(keys) - apex.addToOutbox(keys, dbout) + //console.log(keys) + apex.addToOutbox(object, dbout) await apex.store.db.collection(`${object.id}-queue`).remove( {object: [req.query.id]} ) res.json(dbout) } catch (err) { @@ -340,10 +342,16 @@ client.connect() await apex.store.saveObject(systemUser) apex.systemUser = systemUser } - apex.group = await apex.store.getObject(apex.utils.usernameToIRI('test'), true) - if (!apex.group) { - const group = await createGuppeActor('test', 'test', 'A project built on guppe groups\, it features a moderation ui', icon, 'Group') - await apex.store.saveObject(group) + const grouparray = GROUPS.split(" ") + var g = 0 + while (g < grouparray.length) { + findgroup = await apex.store.getObject(apex.utils.usernameToIRI(grouparray[g]), true) + console.log(findgroup) + if (!findgroup) { + const newgroup = await createGuppeActor(grouparray[g], grouparray[g], 'A project built on guppe groups\, it features a moderation ui', icon, 'Group') + await apex.store.saveObject(newgroup) + } + g++ } let server if (process.env.NODE_ENV === 'production') { diff --git a/web/src/views/Moderation.vue b/web/src/views/Moderation.vue index 4781778..2c56318 100644 --- a/web/src/views/Moderation.vue +++ b/web/src/views/Moderation.vue @@ -2,6 +2,11 @@

Moderation for {{name}}