@@ -88,6 +88,9 @@ def privstr():
88
88
cli .print (" " * indent + "aliases:" + (cli .col (" (none)" , attrs = ["dark" ]) if len (user .aliases ) == 0 else "" ))
89
89
for alias in user .aliases :
90
90
cli .print (" " * indent + " " + alias .aliasname )
91
+ cli .print (" " * indent + "altnames:" + (cli .col (" (none)" , attrs = ["dark" ]) if len (user .altnames ) == 0 else "" ))
92
+ for altname in user .altnames :
93
+ cli .print (" " * indent + " " + altname .altname )
91
94
cli .print (" " * indent + "roles:" + (cli .col (" (none)" , attrs = ["dark" ]) if len (user .roles ) == 0 else "" ))
92
95
for role in user .roles :
93
96
cli .print (" " * indent + " " + role .name )
@@ -127,6 +130,8 @@ def _splitData(args):
127
130
"instead." , "yellow" ))
128
131
data ["aliases" ] = attributes .pop ("alias" , None ) or ()
129
132
data ["aliases_rm" ] = attributes .pop ("remove_alias" , None ) or ()
133
+ data ["altnames" ] = attributes .pop ("altname" , None ) or {}
134
+ data ["altnames_rm" ] = attributes .pop ("remove_altname" , None ) or {}
130
135
data ["props" ] = attributes .pop ("property" , []) + attributes .pop ("storeprop" , [])
131
136
data ["props_rm" ] = attributes .pop ("remove_property" , []) + attributes .pop ("remove_storeprop" , [])
132
137
data ["noldap" ] = attributes .pop ("no_ldap" , False )
@@ -185,6 +190,7 @@ def cliUserCreate(args):
185
190
props .update (data ["attributes" ])
186
191
props ["username" ] = args .username
187
192
props ["aliases" ] = data ["aliases" ]
193
+ props ["altnames" ] = data ["altnames" ]
188
194
properties = data ["properties" ] = {}
189
195
if args .domain :
190
196
from .common import domainCandidates
@@ -400,7 +406,7 @@ def cliUserModify(args):
400
406
cli = args ._cli
401
407
cli .require ("DB" )
402
408
from orm import DB
403
- from orm .users import Aliases
409
+ from orm .users import Aliases , Altnames
404
410
ret , user = _getUser (args )
405
411
if ret :
406
412
return ret
@@ -427,6 +433,11 @@ def cliUserModify(args):
427
433
[Aliases (alias , user ) for alias in data ["aliases" ] if alias not in existing ]
428
434
if data ["aliases_rm" ]:
429
435
user .aliases = [alias for alias in user .aliases if alias .aliasname not in data ["aliases_rm" ]]
436
+ if data ["altnames" ]:
437
+ existing = {a .altname for a in user .altnames }
438
+ [Altnames (altname , user ) for altname in data ["altnames" ] if altname not in existing ]
439
+ if data ["altnames_rm" ]:
440
+ user .altnames = [altname for altname in user .altnames if altname .altname not in data ["altnames_rm" ]]
430
441
except ValueError as err :
431
442
cli .print (cli .col ("Failed to update user: " + err .args [0 ], "red" ))
432
443
return 1
@@ -524,6 +535,7 @@ def proptagAssignCompleter(*args, **kwargs):
524
535
parser .add_argument ("--status" , type = _cliParseStatus , help = "User address status" )
525
536
526
537
parser .add_argument ("--alias" , action = "append" , help = "Add alias" )
538
+ parser .add_argument ("--altname" , action = "append" , help = "Add alternative name" )
527
539
parser .add_argument ("--property" , action = "append" , type = assignment , metavar = "propspec=value" ,
528
540
help = "Set property defined by propspec to value" ).completer = proptagAssignCompleter
529
541
parser .add_argument ("--storeprop" , action = "append" , type = assignment , metavar = "propspec=value" ,
@@ -583,6 +595,7 @@ def deviceParser(parent, action, handler, **kwargs):
583
595
modify .add_argument ("--delete-chat-user" , action = "store_true" , help = "Permanently delete chat user" )
584
596
modify .add_argument ("--no-ldap" , action = "store_true" , help = "Unlink user from ldap object" )
585
597
modify .add_argument ("--remove-alias" , metavar = "ALIAS" , action = "append" , help = "Remove alias" )
598
+ modify .add_argument ("--remove-altname" , metavar = "ALTNAME" , action = "append" , help = "Remove alternative name" )
586
599
modify .add_argument ("--remove-property" , action = "append" , metavar = "propspec" , help = "Remove property from user" )
587
600
modify .add_argument ("--remove-storeprop" , action = "append" , metavar = "propspec" , help = "Remove property from user's store" )
588
601
modify .add_argument ("--username" , help = "Rename user" )
0 commit comments