1
1
import { UseGuards } from '@nestjs/common'
2
2
import { Args , Mutation , Query , Resolver } from '@nestjs/graphql'
3
- import { ApiAuthGraphQLUserGuard } from '@pubkey-link/api-auth-data-access'
3
+ import { ApiAuthGraphQLUserGuard , CtxUserId } from '@pubkey-link/api-auth-data-access'
4
4
import {
5
5
ApiBotService ,
6
6
Bot ,
@@ -17,62 +17,62 @@ export class ApiUserBotResolver {
17
17
constructor ( private readonly service : ApiBotService ) { }
18
18
19
19
@Mutation ( ( ) => Bot , { nullable : true } )
20
- userCreateBot ( @Args ( 'input' ) input : UserCreateBotInput ) {
21
- return this . service . user . createBot ( input )
20
+ userCreateBot ( @CtxUserId ( ) userId : string , @ Args ( 'input' ) input : UserCreateBotInput ) {
21
+ return this . service . user . createBot ( userId , input )
22
22
}
23
23
24
24
@Mutation ( ( ) => Boolean , { nullable : true } )
25
- userDeleteBot ( @Args ( 'botId' ) botId : string ) {
26
- return this . service . user . deleteBot ( botId )
25
+ userDeleteBot ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string ) {
26
+ return this . service . user . deleteBot ( userId , botId )
27
27
}
28
28
29
29
@Query ( ( ) => Bot , { nullable : true } )
30
- userFindOneBot ( @Args ( 'communityId' ) communityId : string ) {
31
- return this . service . user . findOneBot ( communityId )
30
+ userFindOneBot ( @CtxUserId ( ) userId : string , @ Args ( 'communityId' ) communityId : string ) {
31
+ return this . service . user . findOneBot ( userId , communityId )
32
32
}
33
33
34
34
@Mutation ( ( ) => Bot , { nullable : true } )
35
- userUpdateBot ( @Args ( 'botId' ) botId : string , @Args ( 'input' ) input : UserUpdateBotInput ) {
36
- return this . service . user . updateBot ( botId , input )
35
+ userUpdateBot ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'input' ) input : UserUpdateBotInput ) {
36
+ return this . service . user . updateBot ( userId , botId , input )
37
37
}
38
38
39
39
@Query ( ( ) => [ DiscordServer ] , { nullable : true } )
40
- userGetBotServers ( @Args ( 'botId' ) botId : string ) {
41
- return this . service . manager . getBotServers ( botId )
40
+ userGetBotServers ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string ) {
41
+ return this . service . manager . getBotServers ( userId , botId )
42
42
}
43
43
44
44
@Query ( ( ) => DiscordServer , { nullable : true } )
45
- userGetBotServer ( @Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
45
+ userGetBotServer ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
46
46
return this . service . manager . getBotServer ( botId , serverId )
47
47
}
48
48
49
49
@Query ( ( ) => [ DiscordRole ] , { nullable : true } )
50
- userGetBotRoles ( @Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
51
- return this . service . manager . getBotRoles ( botId , serverId )
50
+ userGetBotRoles ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
51
+ return this . service . manager . getBotRoles ( userId , botId , serverId )
52
52
}
53
53
54
54
@Query ( ( ) => [ BotMember ] , { nullable : true } )
55
- userGetBotMembers ( @Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
56
- return this . service . member . getBotMembers ( botId , serverId )
55
+ userGetBotMembers ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
56
+ return this . service . member . getBotMembers ( userId , botId , serverId )
57
57
}
58
58
59
59
@Mutation ( ( ) => Boolean , { nullable : true } )
60
- userLeaveBotServer ( @Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
61
- return this . service . manager . leaveBotServer ( botId , serverId )
60
+ userLeaveBotServer ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
61
+ return this . service . manager . leaveBotServer ( userId , botId , serverId )
62
62
}
63
63
64
64
@Mutation ( ( ) => Boolean , { nullable : true } )
65
- userSyncBotServer ( @Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
66
- return this . service . manager . syncBotServer ( botId , serverId )
65
+ userSyncBotServer ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string , @Args ( 'serverId' ) serverId : string ) {
66
+ return this . service . manager . syncBotServer ( userId , botId , serverId )
67
67
}
68
68
69
69
@Mutation ( ( ) => Boolean , { nullable : true } )
70
- userStartBot ( @Args ( 'botId' ) botId : string ) {
71
- return this . service . manager . startBot ( botId )
70
+ userStartBot ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string ) {
71
+ return this . service . manager . userStartBot ( userId , botId )
72
72
}
73
73
74
74
@Mutation ( ( ) => Boolean , { nullable : true } )
75
- userStopBot ( @Args ( 'botId' ) botId : string ) {
76
- return this . service . manager . stopBot ( botId )
75
+ userStopBot ( @CtxUserId ( ) userId : string , @ Args ( 'botId' ) botId : string ) {
76
+ return this . service . manager . userStopBot ( userId , botId )
77
77
}
78
78
}
0 commit comments