Browse Source

Stop treating people without profile as invalids

@kseistrup says "no profile" or "no avatar" is perfectly normal
behavior and doesn't indicate timeout, error or sin.
You're all forgiven.
master
The Dod 11 years ago
parent
commit
1b576eb4fa
  1. 2
      swizzler.py
  2. 7
      twister.py

2
swizzler.py

@ -125,7 +125,7 @@ class SwizzlerApp(object):
Mining the twister blockchain protects the #twister-verse from attacks like http://twister.net.co/?p=236 Mining the twister blockchain protects the #twister-verse from attacks like http://twister.net.co/?p=236
but unlike doge, we don't have shiny coins to offer "our protectors". but unlike doge, we don't have shiny coins to offer "our protectors".
Instead, they enjoy occasional minutes of fame in the form of the sponsored posts you see here. Instead, they enjoy occasional minutes of fame in the form of the sponsored posts you see here.
We #Respect their their hard earned crypto-graffiti by appreciating them on coffee/spliff/soy-milk/etc. breaks, because that's how we roll yo. We #Respect their hard earned crypto-graffiti by appreciating them on coffee/spliff/soy-milk/etc. breaks, because that's how we roll yo.
Start mining today, and all this (AND moral satisfaction) can be yours.""") Start mining today, and all this (AND moral satisfaction) can be yours.""")
}, },
'messages':twister.get_sponsored_posts(conf['num_messages']), 'messages':twister.get_sponsored_posts(conf['num_messages']),

7
twister.py

@ -41,7 +41,7 @@ class Twister:
"reply":self._format_reply(p['userpost'].get('reply',{})), "reply":self._format_reply(p['userpost'].get('reply',{})),
}) })
return result return result
@functioncache(ignore_instance=True) # cache forever. not supposed to change @functioncache(60*60,ignore_instance=True) # can't cache forever, because maybe user was a skip_cache, in that case it's snafu for an hour :(
def get_twist(self,username,k): def get_twist(self,username,k):
p = self.twister.dhtget(username,'post{0}'.format(k),'s') p = self.twister.dhtget(username,'post{0}'.format(k),'s')
if p: if p:
@ -65,7 +65,8 @@ class Twister:
return {"username":"","fullname":"Nobody"} # Username is empty. Easier for mustache. return {"username":"","fullname":"Nobody"} # Username is empty. Easier for mustache.
result = self.twister.dhtget(username,'profile','s') result = self.twister.dhtget(username,'profile','s')
if not result: if not result:
raise SkipCache("user not found: @{0}".format(username), {"username":username,"fullname":"???"}) #raise SkipCache("user not found: @{0}".format(username), {"username":username,"fullname":username.capitalize()})
return {"username":username,"fullname":username.capitalize()}
user = result[0]['p']['v'] user = result[0]['p']['v']
user['username'] = username # handy user['username'] = username # handy
if not user.get('fullname'): # happens if not user.get('fullname'): # happens
@ -77,7 +78,7 @@ class Twister:
user['avatar'] = '/assets/img/genericPerson.png' user['avatar'] = '/assets/img/genericPerson.png'
except: except:
user['avatar'] = None user['avatar'] = None
raise SkipCache("couldn't get avatar for @{0}, not caching".format(username),user) #raise SkipCache("couldn't get avatar for @{0}, not caching".format(username),user)
return user return user
@functioncache(60*5,ignore_instance=True) @functioncache(60*5,ignore_instance=True)
def local_user_menu(self,active_user=None): def local_user_menu(self,active_user=None):

Loading…
Cancel
Save