pixelfed icon indicating copy to clipboard operation
pixelfed copied to clipboard

Bookmarks API broken JSON output

Open swentel opened this issue 5 years ago • 3 comments

Doing a call on api/v1/bookmarks returns invalid JSON which can't be parsed. Compare with api/v1/favourites for instance which is totally fine.

Experienced on pixelfed.social

Screenshot from a response from a rest client - first one is fine (favourites), second one is broken (bookmarks).

favourites-response

bookmarks-response

swentel avatar Jul 10 '20 06:07 swentel

Fixed in #2324

dansup avatar Jul 14 '20 02:07 dansup

Sorry, but the fix isn't actually working.

The problem is that StatusService::get is returning a json string. And the response of the api is also json, so it's still double encoded.

Not sure what the actual best way forward is. I would opt not to store the json in the StatusService in the cache, that way, calling get on that class returns the object and the implementer can still decide what to do.

swentel avatar Aug 12 '20 12:08 swentel

Ok, playing around with the coldGet and using toArray fixes the return for the bookmarks api controller, however, redis doesn't like to store an array, so that call than crashes.

Calling json_decode in the controller seems really redunant, but maybe that really is the only option, see pull request at https://github.com/pixelfed/pixelfed/pull/2377

swentel avatar Aug 12 '20 12:08 swentel

Fixed!

dansup avatar Jan 03 '24 11:01 dansup