From e5a84e21479d4f34a8d715a272bd794c04b1a1b0 Mon Sep 17 00:00:00 2001 From: insert Date: Wed, 16 Aug 2023 16:24:10 -0400 Subject: [PATCH] stop automatically sharing, instead move it to a db collection --- docker-compose.dev.yml | 17 +++++++------- index.js | 23 +++++++++++++++---- .../requests/activity_inbox_post.http-request | 4 ++-- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 3935ac6..b74694a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -6,6 +6,7 @@ services: restart: always ports: - 8085:8085 + - 8086:8086 env_file: '.env' environment: DB_URL: 'mongodb://mongodb:27017' @@ -14,20 +15,20 @@ services: volumes: # localdev certs - ./certs:/usr/src/guppe/certs - logging: - driver: local - options: - max-size: '10m' + # logging: + # driver: local + # options: + # max-size: '10m' mongodb: image: mongo:4.2 restart: always volumes: - mongo-data:/data/db - logging: - driver: local - options: - max-size: '10m' + #logging: + # driver: local + # options: + # max-size: '10m' volumes: mongo-data: diff --git a/index.js b/index.js index 3adfc73..0f09ab4 100644 --- a/index.js +++ b/index.js @@ -75,14 +75,14 @@ async function createGuppeActor (...args) { return actor } -// Create new groups on demand whenever someone tries to access one +// Piggyback on old function name async function actorOnDemand (req, res, next) { const actor = req.params.actor if (!actor) { return next() - } + } const actorIRI = apex.utils.usernameToIRI(actor) - try { + /*try { if (!(await apex.store.getObject(actorIRI)) && actor.length <= 255) { 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}` @@ -90,6 +90,7 @@ async function actorOnDemand (req, res, next) { await apex.store.saveObject(actorObj) } } catch (err) { return next(err) } + */ next() } 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 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 } // automatically accept follow requests @@ -277,6 +286,12 @@ client.connect() await apex.store.saveObject(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 if (process.env.NODE_ENV === 'production') { if (PROXY_MODE) { diff --git a/test/requests/activity_inbox_post.http-request b/test/requests/activity_inbox_post.http-request index dcb8286..20c48a0 100644 --- a/test/requests/activity_inbox_post.http-request +++ b/test/requests/activity_inbox_post.http-request @@ -1,7 +1,7 @@ { "body": { "content": "ew0KICAiQGNvbnRleHQiOiAiaHR0cHM6Ly93d3cudzMub3JnL25zL2FjdGl2aXR5c3RyZWFtcyIsDQogICJ0eXBlIjogIkNyZWF0ZSIsDQogICJpZCI6ICJodHRwczovL2V4YW1wbGUubmV0L35tYWxsb3J5Lzg3Mzc0IiwNCiAgImFjdG9yIjogImh0dHBzOi8vZXhhbXBsZS5uZXQvfm1hbGxvcnkiLA0KICAib2JqZWN0Ijogew0KICAgICJpZCI6ICJodHRwczovL2V4YW1wbGUuY29tL35tYWxsb3J5L25vdGUvNzIiLA0KICAgICJ0eXBlIjogIk5vdGUiLA0KICAgICJhdHRyaWJ1dGVkVG8iOiAiaHR0cHM6Ly9leGFtcGxlLm5ldC9+bWFsbG9yeSIsDQogICAgImNvbnRlbnQiOiAiVGhpcyBpcyBhIG5vdGUiLA0KICAgICJwdWJsaXNoZWQiOiAiMjAxNS0wMi0xMFQxNTowNDo1NVoiLA0KICAgICJ0byI6IFsiaHR0cHM6Ly9leGFtcGxlLm9yZy9+am9obi8iXSwNCiAgICAiY2MiOiBbImh0dHBzOi8vZXhhbXBsZS5jb20vfmVyaWsvZm9sbG93ZXJzIiwNCiAgICAgICAgICAgImh0dHBzOi8vd3d3LnczLm9yZy9ucy9hY3Rpdml0eXN0cmVhbXMjUHVibGljIl0NCiAgfSwNCiAgInB1Ymxpc2hlZCI6ICIyMDE1LTAyLTEwVDE1OjA0OjU1WiIsDQogICJ0byI6IFsiaHR0cHM6Ly9leGFtcGxlLm9yZy9+am9obi8iXSwNCiAgImNjIjogWyJodHRwczovL2V4YW1wbGUuY29tL35lcmlrL2ZvbGxvd2VycyIsDQogICAgICAgICAiaHR0cHM6Ly93d3cudzMub3JnL25zL2FjdGl2aXR5c3RyZWFtcyNQdWJsaWMiXQ0KfQ==", - "file": "c:\\Users\\William\\Desktop\\activity.json", + "file": "./data.json", "fileSize": 736 }, "headers": { @@ -10,5 +10,5 @@ }, "method": "POST", "title": "New HTTP Request", - "url": "http://localhost:3000/u/dummy/inbox" + "url": "http://apdev.insertapp.net:8085/u/test/inbox" } \ No newline at end of file