showing stripe subscribers. loading really slow.
This commit is contained in:
@@ -21,7 +21,7 @@ export default class Network {
|
||||
.strict()
|
||||
|
||||
get(id) {
|
||||
if(typeof id === "string") {
|
||||
if(id.length > 1) {
|
||||
id = id.split("-")[1]
|
||||
}
|
||||
let index = this.indices[0] + (id - 1)
|
||||
|
||||
@@ -74,11 +74,14 @@ class Server {
|
||||
const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
|
||||
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
|
||||
const members = db.members.getByNetwork(networkId)
|
||||
let stripeMembers = await payments.getCustomers(networkId)
|
||||
stripeMembers = stripeMembers.data
|
||||
|
||||
res.json({
|
||||
join,
|
||||
contact,
|
||||
members
|
||||
members,
|
||||
stripeMembers
|
||||
});
|
||||
} else {
|
||||
const members = db.members.getByNetwork(networkId)
|
||||
|
||||
@@ -48,12 +48,16 @@ export default class PaymentsHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static async getCustomers() {
|
||||
static async getCustomers(networkId) {
|
||||
let network = global.db.networks.get(networkId)
|
||||
if(!network.stripeAccountId) {
|
||||
throw new Error("Can't get customers for account that doesn't exist!")
|
||||
}
|
||||
const customers = await stripe.customers.list(
|
||||
{ limit: 100 },
|
||||
{ stripeAccount: 'acct_connected_account_id' }
|
||||
{ stripeAccount: network.stripeAccountId }
|
||||
);
|
||||
console.log(customers)
|
||||
return customers
|
||||
}
|
||||
|
||||
static async newSubscription(req, res) {
|
||||
|
||||
@@ -65,6 +65,7 @@ export default class Socket {
|
||||
payload = jwt.verify(token, process.env.JWT_SECRET);
|
||||
} catch(e) {
|
||||
console.error("error: jwt is expired ", e)
|
||||
return
|
||||
}
|
||||
ws.userEmail = payload.email;
|
||||
|
||||
@@ -87,7 +88,6 @@ export default class Socket {
|
||||
try {
|
||||
const text = msg.toString();
|
||||
const req = JSON.parse(text);
|
||||
console.log(req)
|
||||
|
||||
if(this.appOperationSchema.safeParse(req).success) {
|
||||
this.handleAppOperation(req, ws)
|
||||
@@ -127,7 +127,6 @@ export default class Socket {
|
||||
}
|
||||
|
||||
async handleFunction(req, ws) {
|
||||
console.log("func call: ", req.name, req.args)
|
||||
let responseData = await server[req.name](...req.args)
|
||||
|
||||
let response = {
|
||||
@@ -135,8 +134,6 @@ export default class Socket {
|
||||
}
|
||||
response.data = responseData
|
||||
|
||||
console.log(response)
|
||||
|
||||
if(!this.functionCallSchema.safeParse(response).success) throw new Error("Socket.handleMessage: Outgoing ws message has incorrect format!")
|
||||
ws.send(JSON.stringify(response))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user