You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-03 00:33:22 +03:00 
			
		
		
		
	Support sending invite reasons with /invite command
Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
		@@ -441,15 +441,14 @@ export const Commands = [
 | 
			
		||||
    }),
 | 
			
		||||
    new Command({
 | 
			
		||||
        command: 'invite',
 | 
			
		||||
        args: '<user-id>',
 | 
			
		||||
        args: '<user-id> [<reason>]',
 | 
			
		||||
        description: _td('Invites user with given id to current room'),
 | 
			
		||||
        runFn: function(roomId, args) {
 | 
			
		||||
            if (args) {
 | 
			
		||||
                const matches = args.match(/^(\S+)$/);
 | 
			
		||||
                if (matches) {
 | 
			
		||||
                const [address, reason] = args.split(/\s+(.+)/);
 | 
			
		||||
                if (address) {
 | 
			
		||||
                    // We use a MultiInviter to re-use the invite logic, even though
 | 
			
		||||
                    // we're only inviting one user.
 | 
			
		||||
                    const address = matches[1];
 | 
			
		||||
                    // If we need an identity server but don't have one, things
 | 
			
		||||
                    // get a bit more complex here, but we try to show something
 | 
			
		||||
                    // meaningful.
 | 
			
		||||
@@ -490,7 +489,7 @@ export const Commands = [
 | 
			
		||||
                    }
 | 
			
		||||
                    const inviter = new MultiInviter(roomId);
 | 
			
		||||
                    return success(prom.then(() => {
 | 
			
		||||
                        return inviter.invite([address]);
 | 
			
		||||
                        return inviter.invite([address], reason);
 | 
			
		||||
                    }).then(() => {
 | 
			
		||||
                        if (inviter.getCompletionState(address) !== "invited") {
 | 
			
		||||
                            throw new Error(inviter.getErrorText(address));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user