feat: Added team invite creation
This commit is contained in:
parent
f9c13e5ada
commit
70b0b86a23
@ -3,6 +3,11 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
if (teamId === '@current') {
|
||||
const user = await getUser('@me', event)
|
||||
|
||||
if (!user.team) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'User must be in a team' })
|
||||
}
|
||||
|
||||
teamId = user.team._id.toString()
|
||||
}
|
||||
|
||||
|
15
webv2/server/api/users/[id]/teamInvites.post.ts
Normal file
15
webv2/server/api/users/[id]/teamInvites.post.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { teamId } = await readBody(event)
|
||||
|
||||
const userId: string = event.context.params ? event.context.params.id : '@me'
|
||||
|
||||
const user = await getUser(userId, event)
|
||||
|
||||
const { teamInvites } = await UserModel.findByIdAndUpdate(user._id, {
|
||||
$addToSet: {
|
||||
teamInvites: teamId
|
||||
}
|
||||
}) ?? { teamInvites: [] }
|
||||
|
||||
return teamInvites
|
||||
})
|
@ -18,7 +18,7 @@ const userSchema = new Schema({
|
||||
teamAdmin: Boolean
|
||||
},
|
||||
teamInvites: [
|
||||
Types.ObjectId
|
||||
{ type: Types.ObjectId, ref: 'Team' }
|
||||
]
|
||||
})
|
||||
|
||||
|
2
webv2/types/global.d.ts
vendored
2
webv2/types/global.d.ts
vendored
@ -16,7 +16,7 @@ declare global {
|
||||
uuid: string,
|
||||
username: string
|
||||
},
|
||||
teamInvites: string[],
|
||||
teamInvites: Types.ObjectId[],
|
||||
role: {
|
||||
admin: boolean,
|
||||
moderator: boolean,
|
||||
|
Loading…
Reference in New Issue
Block a user