Forum Discussion

Claudius's avatar
12 years ago
Solved

How to check if a user is sharing their online status?

I have a custom component that displays some profile information for users including their last visit. I'm using the following REST call for that <#assign dateLastVisited = rest("/users/login/${pag...
  • AdamN's avatar
    12 years ago

    Hi Claudius,

     

    This preference is stored as a user setting called "profile.show_online_status". You can obtain the value like any other user setting via the REST API:

    http://lithosphere.lithium.com/t5/rest-api/bd-p/developers-rest-api?leaf-id=Settings.name.name#Settings.name.name

     

    So your call would look like:

    /users/id/77/settings/name/profile.show_online_status

     

    Currently, the possible values are:

    • all
    • none
    • friends_only

    These correspond to the options presented in the UI. The "friends_only" one may give you a little trouble, since you'd have to look up whether or not the person viewing is a friend of the person whose online status they're trying to view. You could also take a conservative approach and lump "friends_only" in with "none".

     

    Alternately, you could try using an attempt/recover block in FreeMarker like you mentioned. If it reaches the "recover" block, you could assume that the user doesn't have permission and not show the status.