Do not accept messages from self JID
This commit is contained in:
parent
bb9a1926f6
commit
e13807442e
3 changed files with 41 additions and 31 deletions
|
@ -143,10 +143,7 @@ class JabberClient:
|
||||||
xmpp.register_plugin('xep_0122') # Data Forms Validation
|
xmpp.register_plugin('xep_0122') # Data Forms Validation
|
||||||
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
||||||
xmpp.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
xmpp.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
||||||
xmpp.register_plugin('xep_0203') # Delayed Delivery
|
|
||||||
xmpp.register_plugin('xep_0249') # Direct MUC Invitations
|
xmpp.register_plugin('xep_0249') # Direct MUC Invitations
|
||||||
xmpp.register_plugin('xep_0297') # Stanza Forwarding
|
|
||||||
xmpp.register_plugin('xep_0356') # Privileged Entity
|
|
||||||
xmpp.register_plugin('xep_0363') # HTTP File Upload
|
xmpp.register_plugin('xep_0363') # HTTP File Upload
|
||||||
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
xmpp.register_plugin('xep_0402') # PEP Native Bookmarks
|
||||||
xmpp.register_plugin('xep_0444') # Message Reactions
|
xmpp.register_plugin('xep_0444') # Message Reactions
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.16'
|
__version__ = '0.1.17'
|
||||||
__version_info__ = (0, 1, 16)
|
__version_info__ = (0, 1, 17)
|
||||||
|
|
|
@ -238,9 +238,19 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
await self['xep_0115'].update_caps(jid=jid)
|
await self['xep_0115'].update_caps(jid=jid)
|
||||||
|
|
||||||
|
|
||||||
# TODO Request for subscription
|
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
jid = message["from"].bare
|
jid = message['from'].bare
|
||||||
|
if jid == self.boundjid.bare:
|
||||||
|
status_type = 'dnd'
|
||||||
|
status_message = ('Slixfeed is not designed to receive messages '
|
||||||
|
'from itself')
|
||||||
|
XmppPresence.send(self, jid, status_message,
|
||||||
|
status_type=status_type)
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
status_message = ('Slixfeed news bot from RSS Task Force')
|
||||||
|
XmppPresence.send(self, jid, status_message)
|
||||||
|
else:
|
||||||
|
# TODO Request for subscription
|
||||||
if (await get_chat_type(self, jid) == 'chat' and
|
if (await get_chat_type(self, jid) == 'chat' and
|
||||||
not self.client_roster[jid]['to']):
|
not self.client_roster[jid]['to']):
|
||||||
XmppPresence.subscription(self, jid, 'subscribe')
|
XmppPresence.subscription(self, jid, 'subscribe')
|
||||||
|
@ -249,8 +259,8 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
XmppPresence.send(self, jid, status_message)
|
XmppPresence.send(self, jid, status_message)
|
||||||
message_subject = 'RSS News Bot'
|
message_subject = 'RSS News Bot'
|
||||||
message_body = 'Share online status to receive updates.'
|
message_body = 'Share online status to receive updates.'
|
||||||
XmppMessage.send_headline(self, jid, message_subject, message_body,
|
XmppMessage.send_headline(self, jid, message_subject,
|
||||||
'chat')
|
message_body, 'chat')
|
||||||
await process.message(self, message)
|
await process.message(self, message)
|
||||||
# chat_type = message["type"]
|
# chat_type = message["type"]
|
||||||
# message_body = message["body"]
|
# message_body = message["body"]
|
||||||
|
@ -1395,29 +1405,32 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
# form, this check is being done just in case.
|
# form, this check is being done just in case.
|
||||||
jid = session['from'].bare
|
jid = session['from'].bare
|
||||||
if jid == config.get_value('accounts', 'XMPP', 'operator'):
|
if jid == config.get_value('accounts', 'XMPP', 'operator'):
|
||||||
if not self.is_component: # This will be changed with XEP-0222 XEP-0223
|
if self.is_component:
|
||||||
|
# NOTE This will be changed with XEP-0222 XEP-0223
|
||||||
|
text_info = ('Subscriber management options are '
|
||||||
|
'currently not available for Slixfeed '
|
||||||
|
'running as component. Once support for '
|
||||||
|
'XEP-0222 and XEP-0223 be added, this '
|
||||||
|
'panel will be usable for components as '
|
||||||
|
'well.')
|
||||||
|
session['has_next'] = False
|
||||||
|
session['next'] = None
|
||||||
|
session['notes'] = [['info', text_info]]
|
||||||
|
else:
|
||||||
form = self['xep_0004'].make_form('form', 'Admin Panel')
|
form = self['xep_0004'].make_form('form', 'Admin Panel')
|
||||||
form['instructions'] = 'Administration actions'
|
form['instructions'] = 'Administration actions'
|
||||||
options = form.add_field(var='action',
|
options = form.add_field(var='action',
|
||||||
ftype='list-single',
|
ftype='list-single',
|
||||||
label='Action',
|
label='Manage',
|
||||||
desc='Select action type.',
|
desc='Select action type.',
|
||||||
value='subscribers',
|
value='subscribers',
|
||||||
required=True)
|
required=True)
|
||||||
options.addOption('Manage bookmarks', 'bookmarks')
|
options.addOption('Bookmarks', 'bookmarks')
|
||||||
options.addOption('Manage contacts', 'roster')
|
options.addOption('Contacts', 'roster')
|
||||||
options.addOption('Manage subscribers', 'subscribers')
|
options.addOption('Subscribers', 'subscribers')
|
||||||
session['payload'] = form
|
session['payload'] = form
|
||||||
session['next'] = self._handle_admin_action
|
session['next'] = self._handle_admin_action
|
||||||
session['has_next'] = True
|
session['has_next'] = True
|
||||||
else:
|
|
||||||
text_info = ('Subscriber management options are currently not '
|
|
||||||
'available for Slixfeed running as component. '
|
|
||||||
'Once support for XEP-0222 and XEP-0223 be added, '
|
|
||||||
'this panel will be usable for components as well.')
|
|
||||||
session['has_next'] = False
|
|
||||||
session['next'] = None
|
|
||||||
session['notes'] = [['info', text_info]]
|
|
||||||
else:
|
else:
|
||||||
logging.warning('An unauthorized attempt to access bookmarks has '
|
logging.warning('An unauthorized attempt to access bookmarks has '
|
||||||
'been detected!\n'
|
'been detected!\n'
|
||||||
|
@ -1824,7 +1837,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
session['next'] = self._handle_subscribers_complete
|
session['next'] = self._handle_subscribers_complete
|
||||||
session['allow_prev'] = True
|
session['allow_prev'] = True
|
||||||
session['payload'] = form
|
session['payload'] = form
|
||||||
session['prev'] = self._handle_admin
|
session['prev'] = self._handle_advanced
|
||||||
return session
|
return session
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue