Merge pull request #17 from AdvancedAlgos/develop
Fix user to team members on create team
This commit is contained in:
2 files changed
+31
-5
No files matched your search
+29
-4
@@ -155,7 +155,9 @@ const resolvers = {
|
||||
return team
|
||||
},
|
||||
async createTeam(parent, { name, slug, botName, botSlug }, ctx, info) {
|
||||
logger.info(ctx.request.user, 'createTeam ctx.request.user:')
|
||||
logger.info('createTeam ctx.request.user:')
|
||||
logger.info(ctx.request.user)
|
||||
|
||||
const authId = ctx.request.user.sub
|
||||
|
||||
const encodedAuthId = encodeURI(authId)
|
||||
@@ -177,6 +179,7 @@ const resolvers = {
|
||||
|
||||
const platformUrl = 'https://develop.advancedalgos.net/AABrowserAPI/teamSetup/'
|
||||
// const platformUrl = 'http://localhost:1337/AABrowserAPI/teamSetup/'
|
||||
/*
|
||||
logger.info(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
const createPlatformTeam = await axios.get(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
.then((result) => {
|
||||
@@ -198,13 +201,35 @@ const resolvers = {
|
||||
if(await createPlatformTeam === 'Team Name already taken'){
|
||||
return createPlatformTeam
|
||||
}
|
||||
const createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {create: {authId: authId, alias: alias, visible:'true', status: { create: { status: 'ACTIVE', reason: `Created team ${name}`}}}}, role: 'OWNER'}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
*/
|
||||
const existingMember = await ctx.db.query.member({ where: { authId } }, `{id}`)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeam error: ')
|
||||
logger.debug(err, 'existingMember error: ')
|
||||
return err
|
||||
})
|
||||
|
||||
sendTeamCreateConfirmation(email, name, botName)
|
||||
logger.info('existingMember:')
|
||||
logger.info(await existingMember)
|
||||
|
||||
let createTeam
|
||||
if(existingMember.id !== null){
|
||||
logger.info('createTeam with existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {connect: {authId: authId}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Connected to Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
} else {
|
||||
logger.info('createTeam without existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {create: {authId: authId, alias: alias, visible:'true', status: { create: { status: 'ACTIVE', reason: `Created team ${name}`}}}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Created with Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// sendTeamCreateConfirmation(email, name, botName)
|
||||
|
||||
return createTeam
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
import { inspect } from 'util'
|
||||
|
||||
class LoggerService {
|
||||
constructor() {
|
||||
@@ -8,7 +9,7 @@ class LoggerService {
|
||||
format.colorize(),
|
||||
format.timestamp({ format: 'YY/MM/DD HH:mm' }),
|
||||
format.printf(
|
||||
info => `${info.timestamp} - ${info.level}: ${JSON.stringify(info.message)}`
|
||||
info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(inspect(info.message)))}`
|
||||
)
|
||||
),
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user