Register all commands in the roster but show an error message if used when anonymous (#3435)

This commit is contained in:
mathieui 2019-02-24 15:28:28 +01:00
parent 1355d7411e
commit 34f6ad1bac
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3

View file

@ -31,6 +31,17 @@ from poezio.tabs import Tab
log = logging.getLogger(__name__)
def deny_anonymous(func: Callable) -> Callable:
def wrap(self: 'RosterInfoTab', *args, **kwargs):
if self.core.xmpp.anon:
return self.core.information(
'This command is not available for anonymous accounts.',
'Info'
)
return func(self, *args, **kwargs)
return wrap
class RosterInfoTab(Tab):
"""
A tab, splitted in two, containing the roster and infos
@ -652,6 +663,7 @@ class RosterInfoTab(Tab):
self.core.information_buffer)
self.refresh()
@deny_anonymous
@command_args_parser.quoted(1)
def command_password(self, args):
"""
@ -670,6 +682,7 @@ class RosterInfoTab(Tab):
self.core.xmpp.plugin['xep_0077'].change_password(
args[0], callback=callback)
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_deny(self, args):
"""
@ -695,6 +708,7 @@ class RosterInfoTab(Tab):
self.core.information('Subscription to %s was revoked' % jid,
'Roster')
@deny_anonymous
@command_args_parser.quoted(1)
def command_add(self, args):
"""
@ -715,6 +729,7 @@ class RosterInfoTab(Tab):
roster.modified()
self.core.information('%s was added to the roster' % jid, 'Roster')
@deny_anonymous
@command_args_parser.quoted(1, 1)
def command_name(self, args):
"""
@ -747,6 +762,7 @@ class RosterInfoTab(Tab):
subscription=subscription,
callback=callback)
@deny_anonymous
@command_args_parser.quoted(1, 1)
def command_groupadd(self, args):
"""
@ -801,6 +817,7 @@ class RosterInfoTab(Tab):
subscription=subscription,
callback=callback)
@deny_anonymous
@command_args_parser.quoted(3)
def command_groupmove(self, args):
"""
@ -860,6 +877,7 @@ class RosterInfoTab(Tab):
subscription=subscription,
callback=callback)
@deny_anonymous
@command_args_parser.quoted(2)
def command_groupremove(self, args):
"""
@ -905,6 +923,7 @@ class RosterInfoTab(Tab):
subscription=subscription,
callback=callback)
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_remove(self, args):
"""
@ -923,6 +942,7 @@ class RosterInfoTab(Tab):
roster.remove(jid)
del roster[jid]
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_import(self, args):
"""
@ -951,6 +971,7 @@ class RosterInfoTab(Tab):
self.command_add(jid.lstrip('\n'))
self.core.information('Contacts imported from %s' % filepath, 'Info')
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_export(self, args):
"""
@ -1055,6 +1076,7 @@ class RosterInfoTab(Tab):
if contact.pending_in)
return Completion(the_input.new_completion, jids, 1, '', quotify=False)
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_accept(self, args):
"""