Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Include user's index preference in account API #1164

Closed
wants to merge 3 commits into from

Conversation

lightswitch05
Copy link
Contributor

3rd party sites allow indexing of user profiles. Perhaps they will implement noindex if the user's preference is easily accessible. This is an implementation of this request.. I've added hide_from_robots value to the response as well as x-robots-tag: noindex to the header if noindex is enabled.

Example response before the change:

GET http://reddit.local/user/test123/about.json

HTTP/1.0 200 OK
Server: PasteWSGIServer/0.5 Python/2.7.3
Date: Sat, 01 Nov 2014 02:39:04 GMT
content-type: application/json; charset=UTF-8
x-ua-compatible: IE=edge
content-length: 257
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-reddit-pagecache: miss
x-ratelimit-remaining: 297
x-ratelimit-used: 3
x-ratelimit-reset: 56

{
  "kind": "t2",
  "data": {
    "name": "test123",
    "is_friend": false,
    "created": 1414750716,
    "created_utc": 1414721916,
    "link_karma": 1,
    "comment_karma": 0,
    "is_gold": false,
    "is_mod": false,
    "has_verified_email": false,
    "id": "pc"
  }
}

Example Response after the change:

GET http://reddit.local/user/test123/about.json

HTTP/1.0 200 OK
Server: PasteWSGIServer/0.5 Python/2.7.3
Date: Sat, 01 Nov 2014 02:41:17 GMT
content-type: application/json; charset=UTF-8
x-ua-compatible: IE=edge
x-robots-tag: noindex, nofollow
content-length: 256
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-reddit-pagecache: miss
x-ratelimit-remaining: 298
x-ratelimit-used: 2
x-ratelimit-reset: 523

{
  "kind": "t2",
  "data": {
    "name": "test123",
    "is_friend": false,
    "created": 1414750716,
    "hide_from_robots": true,
    "created_utc": 1414721916,
    "link_karma": 1,
    "comment_karma": 0,
    "is_gold": false,
    "is_mod": false,
    "has_verified_email": false,
    "id": "pc"
  }
}

3rd party sites allow indexing of user profiles. Perhaps they will
implement noindex if the user's preference is easily accessible. This is
an implementation of this request:
https://www.reddit.com/r/ideasfortheadmins/comments/2ktryi/allow_reddit_clients_to_respect_users_noindex/
For the account API, if the user prefers not to be indexed, set the HTTP
response header `X-Robots-Tag` to noindex. If the user has no preference
on indexing, then the header is never set.
@xiongchiamiov
Copy link
Contributor

The approach seems reasonable to me.

If we're adding another field to the response data, that should probably be included in the documentation, although I'm not really sure where that lives. Actually from glancing at it, I think we don't currently document responses? This is very unfamiliar territory for me.

👓 @kemitche

@kemitche
Copy link
Contributor

kemitche commented Nov 3, 2014

Responses aren't currently documented.

@@ -33,6 +33,7 @@
import time, pytz
from pylons import c, g
from pylons.i18n import _
from pylons import response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be merged with the pylons imports on line 34

@lightswitch05
Copy link
Contributor Author

Committed requested changes from @kemitche

@xiongchiamiov
Copy link
Contributor

(BTW, if you use the appropriate emoji, a bot in irc will ping us.)

💇

@kemitche
Copy link
Contributor

kemitche commented Nov 4, 2014

🐟

@kemitche kemitche self-assigned this Nov 4, 2014
@kemitche
Copy link
Contributor

kemitche commented Nov 5, 2014

Merged as 7a7210b and 0d6535e

@lightswitch05 Let me know your reddit username

@kemitche kemitche closed this Nov 5, 2014
@lightswitch05
Copy link
Contributor Author

@kemitche my reddit name is lightswitch05. Thanks for getting this merged! 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants