This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1001,14 +1001,29 @@ export const Commands = [
1001
1001
description : _td ( "Opens chat with the given user" ) ,
1002
1002
args : "<user-id>" ,
1003
1003
runFn : function ( roomId , userId ) {
1004
- if ( ! userId || ! userId . startsWith ( "@" ) || ! userId . includes ( ":" ) ) {
1004
+ // easter-egg for now: look up phone numbers through the thirdparty API
1005
+ // (very dumb phone number detection...)
1006
+ const isPhoneNumber = userId && / ^ \+ ? [ 0 1 2 3 4 5 6 7 8 9 ] + $ / . test ( userId ) ;
1007
+ if ( ! userId || ( ! userId . startsWith ( "@" ) || ! userId . includes ( ":" ) ) && ! isPhoneNumber ) {
1005
1008
return reject ( this . getUsage ( ) ) ;
1006
1009
}
1007
1010
1008
1011
return success ( ( async ( ) => {
1012
+ if ( isPhoneNumber ) {
1013
+ const results = await MatrixClientPeg . get ( ) . getThirdpartyUser ( 'im.vector.protocol.pstn' , {
1014
+ 'm.id.phone' : userId ,
1015
+ } ) ;
1016
+ if ( ! results || results . length === 0 || ! results [ 0 ] . userid ) {
1017
+ throw new Error ( "Unable to find Matrix ID for phone number" ) ;
1018
+ }
1019
+ userId = results [ 0 ] . userid ;
1020
+ }
1021
+
1022
+ const roomId = await ensureDMExists ( MatrixClientPeg . get ( ) , userId ) ;
1023
+
1009
1024
dis . dispatch ( {
1010
1025
action : 'view_room' ,
1011
- room_id : await ensureDMExists ( MatrixClientPeg . get ( ) , userId ) ,
1026
+ room_id : roomId ,
1012
1027
} ) ;
1013
1028
} ) ( ) ) ;
1014
1029
} ,
You can’t perform that action at this time.
0 commit comments