File tree Expand file tree Collapse file tree 3 files changed +26
-23
lines changed Expand file tree Collapse file tree 3 files changed +26
-23
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ export class Provisioner extends ProvisioningApi {
182182 return joinRulesEvent . join_rule === 'public' ;
183183 } catch ( e ) {
184184 throw new ApiError (
185- "Could not check if Matrix room is public" ,
185+ "Could not check if room is public" ,
186186 ErrCode . Unknown ,
187187 ) ;
188188 }
Original file line number Diff line number Diff line change @@ -372,13 +372,23 @@ export const SlackApp = () => {
372372 const getLink = useCallback ( async ( ) => {
373373 try {
374374 const link = await client . getLink ( provisioningContext . roomId ) ;
375- setLink ( link ?? null ) ;
375+ setLink ( link ) ;
376376 } catch ( e ) {
377- console . error ( 'Failed to get link:' , e ) ;
378- setError (
379- 'Could not get link status.'
380- + ` ${ e instanceof ProvisioningError ? e . message : '' } `
381- ) ;
377+ if ( e instanceof ProvisioningError ) {
378+ if ( e . errcode === 'SLACK_UNKNOWN_LINK' ) {
379+ setLink ( null ) ;
380+ } else if ( e . errcode === 'SLACK_ROOM_NOT_PUBLIC' ) {
381+ setError ( 'This bridge only allows public Matrix rooms to be linked.' ) ;
382+ } else if ( e . errcode === 'SLACK_NOT_ENOUGH_POWER' ) {
383+ setError ( "You don't have permissions to link this room." ) ;
384+ } else {
385+ console . error ( 'Failed to get link:' , e ) ;
386+ setError ( `Could not get link status. ${ e . message } ` ) ;
387+ }
388+ } else {
389+ console . error ( 'Failed to get link:' , e ) ;
390+ setError ( 'Could not get link status.' ) ;
391+ }
382392 }
383393 } , [ client , provisioningContext ] ) ;
384394
Original file line number Diff line number Diff line change @@ -41,22 +41,15 @@ export class SlackProvisioningClient {
4141 readonly client : ProvisioningClient ,
4242 ) { }
4343
44- getLink = async ( roomId : string ) : Promise < GetLinkResponse | undefined > => {
45- try {
46- const res = await this . client . request (
47- 'POST' ,
48- '/getlink' ,
49- {
50- matrix_room_id : roomId ,
51- } ,
52- ) ;
53- return res as GetLinkResponse ;
54- } catch ( e ) {
55- if ( e instanceof ProvisioningError && e . errcode === 'SLACK_UNKNOWN_LINK' ) {
56- return undefined ;
57- }
58- throw e ;
59- }
44+ getLink = async ( roomId : string ) : Promise < GetLinkResponse > => {
45+ const res = await this . client . request (
46+ 'POST' ,
47+ '/getlink' ,
48+ {
49+ matrix_room_id : roomId ,
50+ } ,
51+ ) ;
52+ return res as GetLinkResponse ;
6053 } ;
6154
6255 listWorkspaces = async ( ) : Promise < SlackWorkspace [ ] > => {
You can’t perform that action at this time.
0 commit comments