@@ -92,6 +92,17 @@ export class ConfluenceClient {
9292 return result ?. results ?? [ ] ;
9393 }
9494
95+ public async lockDownPermissions ( contentId : string , user : User ) {
96+ try {
97+ await this . put < Content > (
98+ `content/${ contentId } /restriction/byOperation/update/user?accountId=${ user . accountId } `
99+ ) ;
100+ } catch ( error ) {
101+ console . log ( "error" , error ) ;
102+ trace ( "lockDownResult Error" , error ) ;
103+ }
104+ }
105+
95106 public async createContent (
96107 user : User ,
97108 content : ContentCreate ,
@@ -107,14 +118,7 @@ export class ConfluenceClient {
107118 const createBody = JSON . stringify ( toCreate ) ;
108119 const result : Content = await this . post < Content > ( "content" , createBody ) ;
109120
110- try {
111- await this . put < Content > (
112- `content/${ result . id } /restriction/byOperation/update/user?accountId=${ user . accountId } `
113- ) ;
114- } catch ( error ) {
115- //Sometimes the API returns the error 'Unexpected end of JSON input'
116- trace ( "lockDownResult Error" , error ) ;
117- }
121+ await this . lockDownPermissions ( result . id ?? "" , user ) ;
118122
119123 return result ;
120124 }
@@ -134,14 +138,7 @@ export class ConfluenceClient {
134138 JSON . stringify ( toUpdate )
135139 ) ;
136140
137- try {
138- const lockDownResult = await this . put < Content > (
139- `content/${ content . id } /restriction/byOperation/update/user?accountId=${ user . accountId } `
140- ) ;
141- } catch ( error ) {
142- //Sometimes the API returns the error 'Unexpected end of JSON input'
143- trace ( "lockDownResult Error" , error ) ;
144- }
141+ await this . lockDownPermissions ( content . id ?? "" , user ) ;
145142
146143 return result ;
147144 }
0 commit comments