Esempio n. 1
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)
Esempio n. 2
0
 def get_destination_param(self, gid, destination, user, param):
     """ returns parameter in gid:destination:user record """
     return self.rc.hget(S1.destination_option_key_fmt(destination),
                         S1.destination_pair_fmt(gid, user, param))
Esempio n. 3
0
 def del_destination_param(self, gid, destination, user, param):
     """ clears parameter in gid:destination:user record """
     self.rc.hdel(S1.destination_option_key_fmt(destination),
                  S1.destination_pair_fmt(gid, user, param))
Esempio n. 4
0
 def set_destination_param(self, gid, destination, user, param, value):
     """ sets parameter in gid:destination:user record """
     self.rc.hset(S1.destination_option_key_fmt(destination),
                  S1.destination_pair_fmt(gid, user, param), value)