stop automatically sharing, instead move it to a db collection

This commit is contained in:
insert 2023-08-16 16:24:10 -04:00
parent ad7fb67c3a
commit e5a84e2147
No known key found for this signature in database
GPG key ID: 8F1F3466FB204C55
3 changed files with 30 additions and 14 deletions

View file

@ -6,6 +6,7 @@ services:
restart: always restart: always
ports: ports:
- 8085:8085 - 8085:8085
- 8086:8086
env_file: '.env' env_file: '.env'
environment: environment:
DB_URL: 'mongodb://mongodb:27017' DB_URL: 'mongodb://mongodb:27017'
@ -14,20 +15,20 @@ services:
volumes: volumes:
# localdev certs # localdev certs
- ./certs:/usr/src/guppe/certs - ./certs:/usr/src/guppe/certs
logging: # logging:
driver: local # driver: local
options: # options:
max-size: '10m' # max-size: '10m'
mongodb: mongodb:
image: mongo:4.2 image: mongo:4.2
restart: always restart: always
volumes: volumes:
- mongo-data:/data/db - mongo-data:/data/db
logging: #logging:
driver: local # driver: local
options: # options:
max-size: '10m' # max-size: '10m'
volumes: volumes:
mongo-data: mongo-data:

View file

@ -75,14 +75,14 @@ async function createGuppeActor (...args) {
return actor return actor
} }
// Create new groups on demand whenever someone tries to access one // Piggyback on old function name
async function actorOnDemand (req, res, next) { async function actorOnDemand (req, res, next) {
const actor = req.params.actor const actor = req.params.actor
if (!actor) { if (!actor) {
return next() return next()
} }
const actorIRI = apex.utils.usernameToIRI(actor) const actorIRI = apex.utils.usernameToIRI(actor)
try { /*try {
if (!(await apex.store.getObject(actorIRI)) && actor.length <= 255) { if (!(await apex.store.getObject(actorIRI)) && actor.length <= 255) {
console.log(`Creating group: ${actor}`) console.log(`Creating group: ${actor}`)
const summary = `I'm a group about ${actor}. Follow me to get all the group posts. Tag me to share with the group. Create other groups by searching for or tagging @yourGroupName@${DOMAIN}` const summary = `I'm a group about ${actor}. Follow me to get all the group posts. Tag me to share with the group. Create other groups by searching for or tagging @yourGroupName@${DOMAIN}`
@ -90,6 +90,7 @@ async function actorOnDemand (req, res, next) {
await apex.store.saveObject(actorObj) await apex.store.saveObject(actorObj)
} }
} catch (err) { return next(err) } } catch (err) { return next(err) }
*/
next() next()
} }
const acceptablePublicActivities = ['delete', 'update'] const acceptablePublicActivities = ['delete', 'update']
@ -187,7 +188,15 @@ app.on('apex-inbox', async ({ actor, activity, recipient, object }) => {
// make sure sender can see it even if they don't follow yet // make sure sender can see it even if they don't follow yet
cc: actor.id cc: actor.id
}) })
apex.addToOutbox(recipient, share) //stop here, we can add the activity to the database, we'll handle it if it passes inspection, otherwise no
console.log(share)
apex.store.db.collection(`${recipient.id}-queue`).insertOne(share)
//console.log(apex.store.db.collection(`${recipient.id}-queue`)
var find = await apex.store.db.collection(`${recipient.id}-queue`).find().toArray()
console.log(await apex.store.db.collection(`${recipient.id}-queue`).find().toArray())
console.log(find)
//apex.addToOutbox(recipient, share)
break break
} }
// automatically accept follow requests // automatically accept follow requests
@ -277,6 +286,12 @@ client.connect()
await apex.store.saveObject(systemUser) await apex.store.saveObject(systemUser)
apex.systemUser = systemUser apex.systemUser = systemUser
} }
apex.systemUser = await apex.store.getObject(apex.utils.usernameToIRI('testing'), true)
if (!apex.systemUser) {
const systemUser = await createGuppeActor('test', 'test', 'A project built on guppe groups\, it features a moderation ui', icon, 'Group')
await apex.store.saveObject(systemUser)
apex.systemUser = systemUser
}
let server let server
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
if (PROXY_MODE) { if (PROXY_MODE) {

View file

@ -1,7 +1,7 @@
{ {
"body": { "body": {
"content": "ew0KICAiQGNvbnRleHQiOiAiaHR0cHM6Ly93d3cudzMub3JnL25zL2FjdGl2aXR5c3RyZWFtcyIsDQogICJ0eXBlIjogIkNyZWF0ZSIsDQogICJpZCI6ICJodHRwczovL2V4YW1wbGUubmV0L35tYWxsb3J5Lzg3Mzc0IiwNCiAgImFjdG9yIjogImh0dHBzOi8vZXhhbXBsZS5uZXQvfm1hbGxvcnkiLA0KICAib2JqZWN0Ijogew0KICAgICJpZCI6ICJodHRwczovL2V4YW1wbGUuY29tL35tYWxsb3J5L25vdG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SIsDQogICAgImNvbnRlbnQiOiAiVGhpcyBpcyBhIG5vdGUiLA0KICAgICJwdWJsaXNoZWQiOiAiMjAxNS0wMi0xMFQxNTowNDo1NVoiLA0KICAgICJ0byI6IFsiaHR0cHM6Ly9leGFtcGxlLm9yZy9+am9obi8iXSwNCiAgICAiY2MiOiBbImh0dHBzOi8vZXhhbXBsZS5jb20vfmVyaWsvZm9sbG93ZXJzIiwNCiAgICAgICAgICAgImh0dHBzOi8vd3d3LnczLm9yZy9ucy9hY3Rpdml0eXN0cmVhbXMjUHVibGljIl0NCiAgfSwNCiAgInB1Ymxpc2hlZCI6ICIyMDE1LTAyLTEwVDE1OjA0OjU1WiIsDQogICJ0byI6IFsiaHR0cHM6Ly9leGFtcGxlLm9yZy9+am9obi8iXSwNCiAgImNjIjogWyJodHRwczovL2V4YW1wbGUuY29tL35lcmlrL2ZvbGxvd2VycyIsDQogICAgICAgICAiaHR0cHM6Ly93d3cudzMub3JnL25zL2FjdGl2aXR5c3RyZWFtcyNQdWJsaWMiXQ0KfQ==",
"file": "c:\\Users\\William\\Desktop\\activity.json", "file": "./data.json",
"fileSize": 736 "fileSize": 736
}, },
"headers": { "headers": {
@ -10,5 +10,5 @@
}, },
"method": "POST", "method": "POST",
"title": "New HTTP Request", "title": "New HTTP Request",
"url": "http://localhost:3000/u/dummy/inbox" "url": "http://apdev.insertapp.net:8085/u/test/inbox"
} }