Commit b5cca868 authored by Madhur Garg's avatar Madhur Garg

Corrects the functionality of /add command in all tabs. Fixes #3395

parent f51d4951
......@@ -508,6 +508,35 @@ class CommandCore:
self.core.bookmarks.save(self.core.xmpp, callback=cb)
else:
self.core.information('No bookmark to remove', 'Info')
@command_args_parser.quoted(1)
def command_add(self, args):
"""
Add the specified JID to the roster, and automatically
accept the reverse subscription
"""
if args is None:
jid = self.core.tabs.current_tab.name
if jid is 'Roster' or 'muc' in jid:
self.core.information('No JID specified', 'Error')
return
else:
if jid in roster and roster[jid].subscription in ('to', 'both'):
return self.core.information('Already subscribed.', 'Roster')
roster.add(jid)
roster.modified()
self.core.information('%s was added to the roster' % jid, 'Roster')
return
jid = safeJID(safeJID(args[0]).bare)
if not str(jid):
self.core.information(
'The provided JID (%s) is not valid' % (args[0], ), 'Error')
return
if jid in roster and roster[jid].subscription in ('to', 'both'):
return self.core.information('Already subscribed.', 'Roster')
roster.add(jid)
roster.modified()
self.core.information('%s was added to the roster' % jid, 'Roster')
@command_args_parser.ignored
def command_reconnect(self):
......
......@@ -1758,6 +1758,14 @@ class Core:
"currently using in this room (instead of default_nick).",
shortdesc="Bookmark a room online.",
completion=self.completion.bookmark)
self.register_command(
'add',
self.command.command_add,
usage='<jid>',
desc='Add the specified JID to your roster, ask them to'
' allow you to see his presence, and allow them to'
' see your presence.',
shortdesc='Add a user to your roster.')
self.register_command(
'reconnect',
self.command.command_reconnect,
......
......@@ -72,13 +72,6 @@ class ConversationTab(OneToOneTab):
desc='Get the last activity of the given or the current contact.',
shortdesc='Get the activity.',
completion=self.core.completion.last_activity)
self.register_command(
'add',
self.command_add,
desc='Add the current JID to your roster, ask them to'
' allow you to see his presence, and allow them to'
' see your presence.',
shortdesc='Add a user to your roster.')
self.register_command(
'invite',
self.core.command.impromptu,
......@@ -257,19 +250,6 @@ class ConversationTab(OneToOneTab):
self.core.xmpp.plugin['xep_0092'].get_version(
jid, callback=self.core.handler.on_version_result)
@command_args_parser.ignored
def command_add(self):
"""
Add the current JID to the roster, and automatically
accept the reverse subscription
"""
jid = self.general_jid
if jid in roster and roster[jid].subscription in ('to', 'both'):
return self.core.information('Already subscribed.', 'Roster')
roster.add(jid)
roster.modified()
self.core.information('%s was added to the roster' % jid, 'Roster')
def resize(self):
self.need_resize = False
if self.size.tab_degrade_y:
......
......@@ -99,14 +99,6 @@ class RosterInfoTab(Tab):
'in your roster), to see your presence.',
shortdesc='Allow a user your presence.',
completion=self.completion_deny)
self.register_command(
'add',
self.command_add,
usage='<jid>',
desc='Add the specified JID to your roster, ask them to'
' allow you to see his presence, and allow them to'
' see your presence.',
shortdesc='Add a user to your roster.')
self.register_command(
'name',
self.command_name,
......@@ -691,27 +683,6 @@ 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):
"""
Add the specified JID to the roster, and automatically
accept the reverse subscription
"""
if args is None:
self.core.information('No JID specified', 'Error')
return
jid = safeJID(safeJID(args[0]).bare)
if not str(jid):
self.core.information(
'The provided JID (%s) is not valid' % (args[0], ), 'Error')
return
if jid in roster and roster[jid].subscription in ('to', 'both'):
return self.core.information('Already subscribed.', 'Roster')
roster.add(jid)
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):
......@@ -951,7 +922,7 @@ class RosterInfoTab(Tab):
log.error('Unable to correct a message', exc_info=True)
return
for jid in lines:
self.command_add(jid.lstrip('\n'))
self.command.command_add(jid.lstrip('\n'))
self.core.information('Contacts imported from %s' % filepath, 'Info')
@deny_anonymous
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment