Exemplo n.º 1
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)
 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)