summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-03-24 19:35:43 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-03-24 19:35:43 +0530
commitb5cca8687d16afafbbfcbd7f74a3c8aa8ca35108 (patch)
tree75660000b4f196fb9120ea81ba2eae3d77b3ca03
parentf51d4951988c50fb306b607cc2b7f8361451f434 (diff)
downloadpoezio-b5cca8687d16afafbbfcbd7f74a3c8aa8ca35108.tar.gz
poezio-b5cca8687d16afafbbfcbd7f74a3c8aa8ca35108.tar.bz2
poezio-b5cca8687d16afafbbfcbd7f74a3c8aa8ca35108.tar.xz
poezio-b5cca8687d16afafbbfcbd7f74a3c8aa8ca35108.zip
Corrects the functionality of /add command in all tabs. Fixes #3395
-rw-r--r--poezio/core/commands.py29
-rw-r--r--poezio/core/core.py8
-rw-r--r--poezio/tabs/conversationtab.py20
-rw-r--r--poezio/tabs/rostertab.py31
4 files changed, 38 insertions, 50 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 4dbb5611..6cf398ff 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -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):
diff --git a/poezio/core/core.py b/poezio/core/core.py
index 6bb19d16..51c304fa 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -1759,6 +1759,14 @@ class Core:
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,
usage="[reconnect]",
diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py
index 60106527..d1ad608c 100644
--- a/poezio/tabs/conversationtab.py
+++ b/poezio/tabs/conversationtab.py
@@ -73,13 +73,6 @@ class ConversationTab(OneToOneTab):
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,
desc='Invite people into an impromptu room.',
@@ -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:
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index 7c941aa9..6d806120 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -100,14 +100,6 @@ class RosterInfoTab(Tab):
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,
usage='<jid> [name]',
@@ -692,27 +684,6 @@ class RosterInfoTab(Tab):
'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