File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Sources/UnidocServer/Operations/Interactions Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -114,17 +114,26 @@ extension Unidoc.WebhookOperation
114
114
in db: Unidoc . Database ,
115
115
at time: UnixMillisecond ) async throws -> HTTP . ServerResponse
116
116
{
117
- guard case . created = event. action
118
- else
119
- {
120
- return . ok( " " )
121
- }
122
-
117
+ let session : Mongo . Session = try await . init( from: db. sessions)
123
118
let user : Unidoc . User = . init( githubInstallation: event. installation,
124
119
initialLimit: db. policy. apiLimitPerReset)
125
- let session : Mongo . Session = try await . init( from: db. sessions)
126
- let _: Unidoc . UserSecrets = try await db. users. update ( user: user, with: session)
127
- return . created( " " )
120
+
121
+ switch event. action
122
+ {
123
+ case . created:
124
+ let _: Unidoc . UserSecrets = try await db. users. update ( user: user, with: session)
125
+ return . created( " " )
126
+
127
+ case . deleted:
128
+ let modified : Unidoc . User ? = try await db. users. modify ( existing: user. id,
129
+ with: session)
130
+ {
131
+ $0 [ . unset] { $0 [ Unidoc . User [ . githubInstallation] ] = ( ) }
132
+ }
133
+ return modified == nil
134
+ ? . notFound( " No such user \n " )
135
+ : . ok( " Removed user installation \n " )
136
+ }
128
137
}
129
138
130
139
private __consuming
You can’t perform that action at this time.
0 commit comments