Example #1
0
    def add_or_update_user(self, uid, updatelist, profileversion, ip, port, profile=None):
        user = get_user(uid)
        newuser = user == None
        if newuser:
            user = create_user(uid)
            if not user:
                warning("community: Unable to create a new user %s\n" % uid)
                return

        if ip != None:
            user.set("ip", ip)
            user.set("port", port)

        if newuser or user.get("v") != profileversion:
            user.update_attributes(updatelist, user.get("v"))

            if profile != None:
                self.got_user_profile(user, profile, None)
            elif not user.inprogress:
                debug("Fetching new profile from user %s\n" % user.tag())
                request = {"t": "uprofile"}
                if self.fetcher.fetch(user, PLUGIN_TYPE_COMMUNITY, request, self.got_user_profile):
                    user.inprogress = True

        elif not user.present and not user.inprogress:
            # User appears and user profile is already up-to-date
            self.request_user_icon(user)
            self.fetch_community_profiles(user)

        if user.update_presence(True):
            self.announce_user(user)
Example #2
0
 def safe_get_user(self, uid, ip):
     if valid_uid(uid) == False or uid == self.myuid:
         return None
     user = self.get_user(uid)
     if user == None:
         # Create a minimal user object for the peer so that we can reply
         return create_user(uid)
     oldip = user.get("ip")
     if ip != None and oldip != None and ip != oldip:
         return None
     if self.is_blacklisted(user):
         return None
     return user