mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Bundle all activityPub in middleware
This way we can disable it for the seeder server which does not need to create RSA keys for all created users
This commit is contained in:
parent
09e23f13bb
commit
a9963fb1a9
18
src/middleware/activityPubMiddleware.js
Normal file
18
src/middleware/activityPubMiddleware.js
Normal file
@ -0,0 +1,18 @@
|
||||
import { generateRsaKeyPair } from '../activitypub/security'
|
||||
import { activityPub } from '../activitypub/ActivityPub'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
CreatePost: async (resolve, root, args, context, info) => {
|
||||
args.activityId = activityPub.generateStatusId(context.user.slug)
|
||||
args.objectId = activityPub.generateStatusId(context.user.slug)
|
||||
return resolve(root, args, context, info)
|
||||
},
|
||||
CreateUser: async (resolve, root, args, context, info) => {
|
||||
const keys = generateRsaKeyPair()
|
||||
Object.assign(args, keys)
|
||||
args.actorId = `${process.env.GRAPHQL_URI}/activitypub/users/${args.slug}`
|
||||
return resolve(root, args, context, info)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import activityPubMiddleware from './activityPubMiddleware'
|
||||
import passwordMiddleware from './passwordMiddleware'
|
||||
import softDeleteMiddleware from './softDeleteMiddleware'
|
||||
import sluggifyMiddleware from './sluggifyMiddleware'
|
||||
@ -25,6 +26,7 @@ export default schema => {
|
||||
// add permisions middleware at the first position (unless we're seeding)
|
||||
// NOTE: DO NOT SET THE PERMISSION FLAT YOUR SELF
|
||||
if (process.env.PERMISSIONS !== 'disabled' && process.env.NODE_ENV !== 'production') {
|
||||
middleware.unshift(activityPubMiddleware)
|
||||
middleware.unshift(permissionsMiddleware.generate(schema))
|
||||
}
|
||||
return middleware
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import createOrUpdateLocations from './nodes/locations'
|
||||
import { generateRsaKeyPair } from '../activitypub/security'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config()
|
||||
@ -7,9 +6,6 @@ dotenv.config()
|
||||
export default {
|
||||
Mutation: {
|
||||
CreateUser: async (resolve, root, args, context, info) => {
|
||||
const keys = generateRsaKeyPair()
|
||||
Object.assign(args, keys)
|
||||
args.actorId = `${process.env.GRAPHQL_URI}/activitypub/users/${args.slug}`
|
||||
const result = await resolve(root, args, context, info)
|
||||
await createOrUpdateLocations(args.id, args.locationName, context.driver)
|
||||
return result
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
import { activityPub } from '../activitypub/ActivityPub'
|
||||
import as from 'activitystrea.ms'
|
||||
import dotenv from 'dotenv'
|
||||
/*
|
||||
@ -13,8 +12,6 @@ dotenv.config()
|
||||
export default {
|
||||
Mutation: {
|
||||
CreatePost: async (object, params, context, resolveInfo) => {
|
||||
params.activityId = activityPub.generateStatusId(context.user.slug)
|
||||
params.objectId = activityPub.generateStatusId(context.user.slug)
|
||||
const result = await neo4jgraphql(object, params, context, resolveInfo, false)
|
||||
|
||||
const session = context.driver.session()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user