Skip to content

Instantly share code, notes, and snippets.

@ernado
Last active January 3, 2016 10:39
Show Gist options
  • Select an option

  • Save ernado/8450956 to your computer and use it in GitHub Desktop.

Select an option

Save ernado/8450956 to your computer and use it in GitHub Desktop.
# ...
def initialize(jid, send=True):
"""
Initializes user by subscribing to friends and sending initial presence
@type jid: unicode
@param jid: client jid
@param send: send presence flag
"""
logger.debug("user api: called init for user %s" % jid)
assert isinstance(jid, unicode)
friends = get_friends(jid)
database.set_friends(jid, friends)
database.unset_polling(jid)
database.unset_processing(jid)
database.set_online(jid)
if friends:
logger.debug("user api: subscribing friends for %s" % jid)
roster_subscribe(jid, friends)
if send:
logger.debug('sending initial presence')
send_init_presence(jid)
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment