Stripe integration flow
This commit is contained in:
@@ -94,7 +94,7 @@ export default class Post {
|
||||
postToEdit.edited = true;
|
||||
|
||||
let { authorId, ...rest } = postToEdit
|
||||
global.db.editNode(this.prefix, id, rest)
|
||||
global.db.updateNode(this.prefix, id, rest)
|
||||
|
||||
return postToEdit
|
||||
} catch(e) {
|
||||
|
||||
@@ -43,15 +43,6 @@ export default class Member {
|
||||
}
|
||||
}
|
||||
|
||||
getByNetwork(id) {
|
||||
let connections = db.MEMBER_IN_NETWORK.getByNetwork(id)
|
||||
let members = []
|
||||
connections.forEach((conn) => {
|
||||
members.push(this.getByID(conn.from))
|
||||
})
|
||||
return members
|
||||
}
|
||||
|
||||
async getPersonalData(id) {
|
||||
const filePath = path.join(global.db.PERSONAL_DATA_PATH, id, "db.json");
|
||||
|
||||
@@ -63,6 +54,15 @@ export default class Member {
|
||||
return result
|
||||
}
|
||||
|
||||
getByNetwork(id) {
|
||||
let connections = db.MEMBER_IN_NETWORK.getByNetwork(id)
|
||||
let members = []
|
||||
connections.forEach((conn) => {
|
||||
members.push(this.getByID(conn.from))
|
||||
})
|
||||
return members
|
||||
}
|
||||
|
||||
getByID(id) {
|
||||
if(typeof id === 'string') {
|
||||
id = id.split("-")[1]
|
||||
|
||||
@@ -14,14 +14,18 @@ export default class Network {
|
||||
apps: z.array(z.string()),
|
||||
logo: z.string(),
|
||||
abbreviation: z.string(),
|
||||
created: z.string()
|
||||
created: z.string(),
|
||||
stripeAccountId: z.string().nullable(),
|
||||
stripeAccessToken: z.string().nullable()
|
||||
})
|
||||
.strict()
|
||||
|
||||
get(stringID) {
|
||||
let id = stringID.split("-")[1]
|
||||
get(id) {
|
||||
if(typeof id === "string") {
|
||||
id = id.split("-")[1]
|
||||
}
|
||||
let index = this.indices[0] + (id - 1)
|
||||
return global.db.nodes[index]
|
||||
return structuredClone(global.db.nodes[index])
|
||||
}
|
||||
|
||||
getByAbbreviation(abbreviation) {
|
||||
@@ -33,6 +37,21 @@ export default class Network {
|
||||
return null
|
||||
}
|
||||
|
||||
update(id, data) {
|
||||
if(data.id || data.created) {
|
||||
throw new Error("Can't update node id or created time!")
|
||||
}
|
||||
let currentObject = this.get(id)
|
||||
let newObject = {...currentObject, ...data}
|
||||
|
||||
try {
|
||||
global.db.updateNode(this.prefix, newObject.id, newObject)
|
||||
} catch(e) {
|
||||
console.error(e)
|
||||
throw new global.ServerError(400, "Failed to add member!");
|
||||
}
|
||||
}
|
||||
|
||||
save(n) {
|
||||
let id = `${this.prefix}-${n.id}`
|
||||
let result = this.schema.safeParse(n)
|
||||
|
||||
Reference in New Issue
Block a user