{"action":"created","issue":{"url":"https://api.github.com/repos/hypothesis/h/issues/2539","labels_url":"https://api.github.com/repos/hypothesis/h/issues/2539/labels{/name}","comments_url":"https://api.github.com/repos/hypothesis/h/issues/2539/comments","events_url":"https://api.github.com/repos/hypothesis/h/issues/2539/events","html_url":"https://github.com/hypothesis/h/pull/2539","id":107977306,"number":2539,"title":"Remove api logic","user":{"login":"tilgovi","id":20818,"avatar_url":"https://avatars.githubusercontent.com/u/20818?v=3","gravatar_id":"","url":"https://api.github.com/users/tilgovi","html_url":"https://github.com/tilgovi","followers_url":"https://api.github.com/users/tilgovi/followers","following_url":"https://api.github.com/users/tilgovi/following{/other_user}","gists_url":"https://api.github.com/users/tilgovi/gists{/gist_id}","starred_url":"https://api.github.com/users/tilgovi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tilgovi/subscriptions","organizations_url":"https://api.github.com/users/tilgovi/orgs","repos_url":"https://api.github.com/users/tilgovi/repos","events_url":"https://api.github.com/users/tilgovi/events{/privacy}","received_events_url":"https://api.github.com/users/tilgovi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-23T18:20:57Z","updated_at":"2015-10-05T10:06:31Z","closed_at":"2015-10-05T10:06:31Z","pull_request":{"url":"https://api.github.com/repos/hypothesis/h/pulls/2539","html_url":"https://github.com/hypothesis/h/pull/2539","diff_url":"https://github.com/hypothesis/h/pull/2539.diff","patch_url":"https://github.com/hypothesis/h/pull/2539.patch"},"body":"WIP just to see what the view functions look like without `h.api.logic`.\r\n\r\nI feel like whatever separation the logic layer provides is not really helpful right now and things seem kind of confused.\r\n\r\nThings that are strange:\r\n\r\n- `h.api.logic` functions raise exceptions with HTTP status codes, even though these are supposed to be \"below\" the HTTP layer\r\n- The `prepare` function is called in logic, but `render` is called in the view, where it seems like those should be on one side of the same interface, perhaps\r\n- We have to pass user information along that was readily available on the request\r\n- Sanitization of input is happening in a logic function where preconditions could instead be assumed.\r\n\r\nThere are individual parts of this that it would be nice to simplify. I think the instinct to pull things out into a logic layer was a nice one, but the problem wasn't that there was view code and logic code together. I think it's just that the logic itself is too complicated.\r\n\r\nThings could get much simpler if:\r\n\r\n- We remove the curious restriction that the `group` field can't be changed, which seems unmotivated.\r\n- We remove the anonymization / retraction support. It's of questionable utility and relies on the client to know more than it can/should (such as whether there are replies, especially in a federated world).\r\n- We could remove the ACLs altogether, really easily, just by saying that only the owner and admins can do anything. The client would then just decide \"can I write/update/delete\" by checking \"am I the author\".\r\n\r\nAt that point, none of these view functions would be more than about eight lines."},"comment":{"url":"https://api.github.com/repos/hypothesis/h/issues/comments/145486026","html_url":"https://github.com/hypothesis/h/pull/2539#issuecomment-145486026","issue_url":"https://api.github.com/repos/hypothesis/h/issues/2539","id":145486026,"user":{"login":"nickstenning","id":3602,"avatar_url":"https://avatars.githubusercontent.com/u/3602?v=3","gravatar_id":"","url":"https://api.github.com/users/nickstenning","html_url":"https://github.com/nickstenning","followers_url":"https://api.github.com/users/nickstenning/followers","following_url":"https://api.github.com/users/nickstenning/following{/other_user}","gists_url":"https://api.github.com/users/nickstenning/gists{/gist_id}","starred_url":"https://api.github.com/users/nickstenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickstenning/subscriptions","organizations_url":"https://api.github.com/users/nickstenning/orgs","repos_url":"https://api.github.com/users/nickstenning/repos","events_url":"https://api.github.com/users/nickstenning/events{/privacy}","received_events_url":"https://api.github.com/users/nickstenning/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T10:06:31Z","updated_at":"2015-10-05T10:06:31Z","body":"Closing. Feel free to reopen if you update it."}}