(Issue #752) Add user-side /data/interests (JSON), remove site-side /misc/interestdata

Add a JSON API endpoint for retrieving user interests, and remove the old script.

No replacement is being made for the previous ?int= functionality to find the count for a single interest; this was apparently rarely used.

The new file is based on the Edges.pm file, so I've left the credits for that file as I'm not sure how much of the stuff I deleted is theirs. (Commit b879927 shows the exact amount that was deleted.)

Fixes #752.
I think another pull request is fine!





On Fri, Jul 4, 2014, at 11:33 PM, Sophira wrote:

  In cgi-bin/DW/Controller/Interests.pm:
> +       my ( $code, $message ) = @_;
> +       $r->status( $code );
> +       $format->( $r, { error => $message } );
> +
> +       return $r->OK;
> +    };
> +
> +    # Load the account or error
> +    return $error_out->( $r->NOT_FOUND, 'Need account name as user pa
rameter' ) unless $opts->username;
> +    my $u = LJ::load_user_or_identity( $opts->username )
> +        or return $error_out->( $r->NOT_FOUND, "invalid account");
> +
> +    # Check for other conditions
> +    return $error_out->( $r->HTTP_GONE, 'expunged' ) if $u->is_expung
ed;
> +    return $error_out->( $r->FORBIDDEN, 'suspended' ) if $u->is_suspe
nded;
> +    return $error_out->( $r->NOT_FOUND, 'deleted' ) if $u->is_deleted
;

  Well, I guess I could do that, sure. I'd need to separate
  out the actual data generation into another sub, but that
  might be a good idea anyway, since that way we can reduce
  the cope duplication in Edges.pm and Interests.pm, which
  might also make it easier to do user data controllers in the
  future.

  Probably worth doing that in another pull request though, I
  think, unless you want to expand the scope of this one?

  —

Reply to this email directly or [1]view it on GitHub.

References

1. https://github.com/dreamwidth/dw-free/pull/757/files#r14563448