示例#1
0
 def bind_destination(self, gid, destination, user):
     # bind source and destination
     self._append_hfield(S1.destination_key_fmt(destination), gid, user)
     # bind destination to source
     self._append_hfield(S1.destination_source_key_fmt(destination), user,
                         gid)
     # append destination list for the source
     self._append_hfield(S1.destination_key_fmt(S1.destinations_key()), gid,
                         destination)
示例#2
0
    def remove_binding(self, gid, destination, user, clean=False):
        """ clears binding created by bind_user() """
        self.logger.info('Unbinding GID: [{0}] -/-> [{1}:{2}]'.format(
            gid, destination, user))
        self.add_log(
            gid, 'Unbinding Google+ [{0}] -/-> [{1}:{2}]'.format(
                gid, destination, user))

        # remove binding update option
        self.rc.hdel(S1.destination_option_key_fmt(destination),
                     S1.destination_pair_fmt(gid, user, S1.updated_key()))

        # remove destination user id from list of destinations for this gid
        self._delete_hfield_item(S1.destination_key_fmt(destination), gid,
                                 user)

        # remove gid from list of sources for this destination user
        self._delete_hfield_item(S1.destination_source_key_fmt(destination),
                                 user, gid)

        # clean linked accounts
        # find the owner(s) of the destination:user pair
        self.purge_gid_links(destination, user)

        # the gid->destination:user link is broken
        # clear this relationship
        self.remove_linked_account(gid,
                                   S1.provider_root_key(destination, user),
                                   bag='dst')

        # remove destination binding if no bindings to this destination left
        bound_users = self.get_destination_users(gid, destination)
        if not (bound_users and len(bound_users)):
            self.logger.info('No links remain for [{0} --> {1}]'.format(
                gid, destination))
            # remove destination from gid destination list
            self._delete_hfield_item(
                S1.destination_key_fmt(S1.destinations_key()), gid,
                destination)

        # keep message map for the destination:user -- user may re-bind later with new token
        # unless forced to clean all
        # keep filters unless forced to clean!
        if clean:
            self.filter.del_filter(destination, gid, user)
            self.filter.del_message_id_map(destination, user)

        # clear bound timestamp
        self.del_destination_param(gid, destination, user, S1.bound_key())

        # check_orphan() will stop polling the gid if nothing is bound to it
        self.check_orphan(gid, 0)
示例#3
0
 def get_destinations(self, gid):
     """ returns list of destinations associated with this source gid """
     return self._get_hfield_list(
         S1.destination_key_fmt(S1.destinations_key()), gid)