more moderation ui tweeks, renaming and description, env var for groups

This commit is contained in:
insert 2023-08-18 18:32:05 -04:00
parent 1e2a2a67f8
commit 94e5d8df64
No known key found for this signature in database
GPG key ID: 8F1F3466FB204C55
2 changed files with 71 additions and 23 deletions

View file

@ -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') {

View file

@ -2,6 +2,11 @@
<div class="w3-container">
<h1>Moderation for {{name}} </h1>
<ul style="list-style-type:none;">
<h5>Description</h5>
<input v-model="userdescription" :placeholder="userdata.summary[0]" />
<h5>Display Name</h5>
<input v-model="username" :placeholder="userdata.preferredUsername[0]" />
<button class="save" v-on:click="save(name, userdescription, username)">Save</button>
<li v-for="item in queue">
<a :href="item.object[0]" target="_blank">{{ item.object[0] }}</a>
<button class="deny" v-on:click="deny(name, item.object[0])">Deny</button>
@ -14,7 +19,7 @@
<script>
export default {
name: 'home',
name: 'ModerationUi',
components: {},
props: {
name: {
@ -27,6 +32,7 @@ export default {
queue: [],
error: null,
name: this.name,
userdata: this.userdata,
domain: window.location.host
}
},
@ -78,7 +84,18 @@ export default {
this.queue = json
})
.catch(err => (this.error = err.message))
}
},
save: function (name, description, username) {
window.fetch(`/mod/changedata?name=${name}&description=${description}&username=${username}`, {
method: 'get',
headers: {
accept: 'application/json'
}
}).then(res => res.json())
.then(json => {
console.log("test3")
console.log(json)
})
},
created () {
window.fetch(`/mod/data?name=${this.name}`, {
@ -93,10 +110,30 @@ export default {
this.queue = json
})
.catch(err => (this.error = err.message))
}
window.fetch(`/mod/userinfo?name=${this.name}`, {
method: 'get',
headers: {
accept: 'application/json'
}
}).then(res => res.json())
.then(json => {
console.log("test4")
console.log(json)
this.userdata = json
})
.catch(err => (this.error = err.message))
}
}
</script>
<script setup>
import { ref } from 'vue'
const userdescription = ref('');
const username = ref('');
</script>
<style>
button.approve {
margin-left:5em;
@ -106,4 +143,7 @@ export default {
margin-left:5em;
float:right;
}
li {
margin: 12px 0;
}
</style>