def removeFriend(self, dbID, shadowMode=False):
     error = self._checkCooldown(CLIENT_ACTION_ID.REMOVE_FRIEND)
     if error and not shadowMode:
         return (False, error)
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if not contact:
         return (False,
                 ClientContactError(
                     CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     if contact.getItemType() not in XMPP_ITEM_TYPE.ROSTER_ITEMS:
         return (False,
                 ClientContactError(CONTACT_ERROR_ID.ROSTER_ITEM_NOT_FOUND,
                                    contact.getFullName()))
     jid = contact.getJID()
     tasks = [
         roster_tasks.RemoveRosterItemTask(jid,
                                           contact.getName(),
                                           groups=contact.getGroups())
     ]
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     if not shadowMode:
         self.__cooldown.process(CLIENT_ACTION_ID.REMOVE_FRIEND)
     return self.__addTasks(CLIENT_ACTION_ID.REMOVE_FRIEND, jid, shadowMode,
                            *tasks)
Пример #2
0
 def removeIgnored(self, dbID):
     error = self._checkCooldown(CLIENT_ACTION_ID.REMOVE_IGNORED)
     if error:
         return (False, error)
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if not contact:
         return (False,
                 ClientContactError(
                     CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     itemType = contact.getItemType()
     if itemType not in XMPP_ITEM_TYPE.PERSISTENT_BLOCKING_LIST:
         return (False,
                 ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_NOT_FOUND,
                                    contact.getFullName()))
     jid = contact.getJID()
     tasks = [block_tasks.RemoveBlockItemTask(jid, contact.getName())]
     if itemType == XMPP_ITEM_TYPE.ROSTER_BLOCK_ITEM:
         tasks.append(
             roster_tasks.RemoveRosterItemTask(
                 jid,
                 contact.getName(),
                 groups=contact.getItem().getRosterGroups()))
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     self.__cooldown.process(CLIENT_ACTION_ID.REMOVE_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.REMOVE_IGNORED, jid, *tasks)
Пример #3
0
 def cancelFriendship(self, dbID):
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     result, error = self.canCancelFriendship(contact)
     if not result:
         return (result, error)
     jid = contact.getJID()
     tasks = [sub_tasks.CancelSubscriptionTask(jid)]
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     return self.__addTasks(CLIENT_ACTION_ID.CANCEL_FRIENDSHIP, jid, *tasks)
Пример #4
0
 def sync(self, name, groups, sub = None, clanInfo = None):
     user = self._doSync(name, groups, sub, clanInfo)
     if user and user.getItemType() != XMPP_ITEM_TYPE.ROSTER_ITEM and canNoteAutoDelete(user):
         self._removeNotes.add(user.getID())
     self._result = TASK_RESULT.REMOVE
     if self._chain:
         self._result |= TASK_RESULT.CLONE
     elif self._removeNotes:
         self._result |= TASK_RESULT.CREATE_SEQ
     return self._result
Пример #5
0
 def cancelFriendship(self, dbID):
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     result, error = self.canCancelFriendship(contact)
     if not result:
         return (result, error)
     jid = contact.getJID()
     tasks = [sub_tasks.CancelSubscriptionTask(jid)]
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     return self.__addTasks(CLIENT_ACTION_ID.CANCEL_FRIENDSHIP, jid, *tasks)
Пример #6
0
 def removeFriend(self, dbID):
     error = self.__checkCooldown(CLIENT_ACTION_ID.REMOVE_FRIEND)
     if error:
         return (False, error)
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if not contact:
         return (False, ClientContactError(CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     if contact.getItemType() != XMPP_ITEM_TYPE.ROSTER_ITEM:
         return (False, ClientContactError(CONTACT_ERROR_ID.ROSTER_ITEM_NOT_FOUND, contact.getFullName()))
     jid = contact.getJID()
     self.__cooldown.process(CLIENT_ACTION_ID.REMOVE_FRIEND)
     tasks = [roster_tasks.RemoveRosterItemTask(jid, contact.getName(), groups=contact.getGroups())]
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     return self.__addTasks(CLIENT_ACTION_ID.REMOVE_FRIEND, jid, *tasks)
Пример #7
0
 def removeIgnored(self, dbID):
     error = self.__checkCooldown(CLIENT_ACTION_ID.REMOVE_IGNORED)
     if error:
         return (False, error)
     contact = self.usersStorage.getUser(dbID, PROTO_TYPE.XMPP)
     if not contact:
         return (False, ClientContactError(CONTACT_ERROR_ID.CONTACT_ITEM_NOT_FOUND))
     itemType = contact.getItemType()
     if itemType not in XMPP_ITEM_TYPE.BLOCKING_LIST:
         return (False, ClientContactError(CONTACT_ERROR_ID.BLOCK_ITEM_NOT_FOUND, contact.getFullName()))
     jid = contact.getJID()
     tasks = [block_tasks.RemoveBlockItemTask(jid, contact.getName())]
     if itemType == XMPP_ITEM_TYPE.ROSTER_BLOCK_ITEM:
         tasks.append(roster_tasks.RemoveRosterItemTask(jid, contact.getName()))
     if note_tasks.canNoteAutoDelete(contact):
         tasks.append(note_tasks.RemoveNoteTask(jid))
     self.__cooldown.process(CLIENT_ACTION_ID.REMOVE_IGNORED)
     return self.__addTasks(CLIENT_ACTION_ID.REMOVE_IGNORED, jid, *tasks)