LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.25k stars 879 forks source link

[Bug]: `my_vote` return null from `getPosts` call but with proper value from `getPost` call #3197

Closed brunofin closed 1 year ago

brunofin commented 1 year ago

Requirements

Summary

I am using lemmy-js-client to interact with the backend.

I am trying to get the user's current vote status on a post from the aggregated posts response from the corresponding endpoint for the getPosts function defined in the js-client. The value there is always null regardless of the post being upvoted or downvoted.

If I go and use getPost to fetch that post specifically, the value at post.post_view.my_vote will return the proper value set in that post as 1, 0, or -1.

Steps to Reproduce

  1. Upvote a post. For ease you can do this on the web interface of the instance you are using to test. Save the post id.
  2. get a list of posts from and authenticated request to getPosts. Search for post id and verify my_vote is null.
  3. Get that post from getPost and verify post_view.my_vote is 1.

Technical Details

here's the log for the post object from getPosts:

 LOG  {"community": {"actor_id": "https://beehaw.org/c/support", "banner": "https://beehaw.org/pictrs/image/439dfc09-d740-4a9c-a03e-a41d627d342b.jpeg", "deleted": false, "description": "Support and meta community for Beehaw. Ask your questio
ns about the community, technical issues, and other such things here.
A brief FAQ for lurkers and new users can be found [here](https://beehaw.org/post/452132).
Our [June 2023 financial update is here](https://beehaw.org/post/428209).
For a refresher on our philosophy, see also [What is Beehaw?](https://beehaw.org/post/107014), [Beehaw is a Community](https://beehaw.org/post/140733), and [A few thoughts on Beehaw's design](https://beehaw.org/post/439918) ([second half](ht
tps://beehaw.org/comment/84235)).
---
This community's icon was made by Aaron Schneider, under the [CC-BY-NC-SA 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/).", "hidden": false, "icon": "https://beehaw.org/pictrs/image/b101eefc-9ec4-4c03-8913-78a4ebacd206.png"
, "id": 3, "instance_id": 664, "local": true, "name": "support", "nsfw": false, "posting_restricted_to_mods": false, "published": "2022-01-28T12:49:35.450320", "removed": false, "title": "Beehaw Support", "updated": "2023-06-15T17:01:56.3469
59"}, "counts": {"comments": 217, "downvotes": 0, "featured_community": true, "featured_local": true, "hot_rank": 1, "hot_rank_active": 1, "id": 40768, "newest_comment_time": "2023-06-19T12:31:55.208013", "newest_comment_time_necro": "2023-0
6-09T00:35:08.500367", "post_id": 452132, "published": "2023-06-07T01:27:26.508415", "score": 526, "upvotes": 526}, "creator": {"actor_id": "https://beehaw.org/u/alyaza", "admin": true, "avatar": "https://beehaw.org/pictrs/image/018439e1-9b4
d-4100-9ed1-78b4fa2cd68c.png", "ban_expires": null, "banned": false, "banner": "https://beehaw.org/pictrs/image/b508b38e-6171-4bd6-b736-ab68084c090b.png", "bio": "internet gryphon. admin of Beehaw, mostly publicly interacting with people. no
nbinary. they/she", "bot_account": false, "deleted": false, "display_name": "alyaza", "id": 8, "inbox_url": "https://beehaw.org/u/alyaza/inbox", "instance_id": 664, "local": true, "matrix_user_id": null, "name": "alyaza", "published": "2022-
01-28T22:43:09.245896", "shared_inbox_url": "https://beehaw.org/inbox", "updated": "2022-08-24T13:55:50.404458"}, "creator_banned_from_community": false, "creator_blocked": false, "my_vote": null, "post": {"ap_id": "https://beehaw.org/post/4
52132", "body": "hey folks. here's a new FAQ on the community, since the currently pinned thread is a bit haphazard and crammed now, and we've had more time to go over stuff.
##### What is Beehaw?

in summary, we're a community that wants to cultivate a sense of real belonging to something, to foster meaningful conversations, and to ensure everyone feels valued and respected in a way that isn't the case with other social media out ther
e. we've thought and written a lot about this. if you'd like more than that summary, we strongly encourage you to read the following three essays, which explain how this community is run, what we priortize in running it, and why we've design
ed it this way generally:

* [What is Beehaw?](https://beehaw.org/post/107014)
* [Beehaw is a Community](https://beehaw.org/post/140733)
* [A few thoughts on Beehaw's design](https://beehaw.org/post/439918)

##### This sounds very cool! How do I join?

[you can register here](https://beehaw.org/signup).

**you don't need to write a whole essay, however: *please* answer the question fully, and try to engage with at least some of the content above/on the sidebar before you register.**

this is not personal, but we've grown a lot in the past week and are primarily interested in users who really care for the philosophy of our community. if you don't answer the question fully, you will likely get caught in registration limbo
(see below).

##### How long should I expect to wait to be approved?

**anywhere from a few minutes to a day. in general, try logging in after about 24 hours.**

if you haven't been approved within 24 hours your application is almost certainly in limbo because you didn't answer our entry question to our satisfaction. this doesn't mean we're rejecting you, per se, but it generally means we didn't thin
k you engaged with the content above/on the sidebar. **we *finally* have a hack solution to denials devised and automated, so as of now if you're a new registration you should eventually get a denial email (and have the username you chose wi
ped, so you can reapply with it). if you're in registration limbo you should also *eventually* get an email, although we have no idea how long it'll take to get.**

**if you *have* been approved and you used an email to sign up you should receive an email for that, although it might be marked as spam.** we're still trying to get Gmail to consistently take our emails, so again the 24 hour rule is best if
 you're unsure or haven't received one.

if you have issues of this sort, please [report them in the following thread](https://beehaw.org/post/448510)!

##### I'm in! How can I keep Beehaw running, or otherwise contribute?

our instance is 100% user-funded. you can one-time donate or become a monthly donor [here](https://opencollective.com/beehaw/donate). you can donate anonymously both ways. as far as we're aware cryptocurrency [is accepted by OpenCollective](
https://opencollective.com/foundation/updates/ocf-can-now-receive-cryptocurrency), it's just more laborious and you'll probably have to contact them to clear it.

if you have volunteer labor or advice you're willing to give us on how to keep the site running smoothly, we also generally appreciate that. our Matrix and Discord communities are the best way to offer that stuff to us.

##### How do I help keep the community running smoothly?

be considerate! think about the things you say and how you want to say them; be kind and charitable; don't assume the worst of people; but above all: Be(e) nice!

it might seem trite, but genuinely we've found there is no better distillation of what we want to accomplish here than that ethos. if something makes you feel like that ethos is being violated, err on the side of caution and report it (on de
sktop it's the flag button in the three dot menu on any post). it can't hurt. so far though we've found most people kind of *know* what we mean, and we're hopeful you'll be able to pick up on that too.

as for non-moderation ways you can keep things running: contribute to discussions! share stuff you find interesting! contribute your expertise and help out folks when they ask for it! it's okay—and very understandable—to lurk based on the to
xicity commonplace on other social media, but we really do try to make this space as welcoming as possible to everyone here and we hope you'll find it a safer place to come out of your online shell.

##### What else should I know?

we always take feedback. while we can't *promise* any changes, you can provide thoughts and comments on just about anything on the site in Beehaw Support, or on Discord or Matrix (where we maintain real-time chat). we try to get a sense of w
hat the community wants and needs all the time, so we'll frequently be asking for input from you to help inform our decisions.

[downvotes are disabled on this instance and will probably always be](https://beehaw.org/comment/29314). we find them unproductive. [communities cannot be made by users on here](https://beehaw.org/post/140733). we do take feedback on what ge
ts made and when to make communities, as a part of the above point. you can always find a running list of communities we have [at this link](https://beehaw.org/communities), or under the Communities button on desktop.

we are all volunteers, and this is not a job for us. we would like to not have it be one, so we can just be members of the community with all of you. please help keep it that way!

in the very, very long term, [we aspire to become a co-op or similar](https://beehaw.org/comment/67350), as a part of fulfilling our ethos.

as with the last thread, feel free to sound off on other questions you have. i, other mods, and community members will try to get to them as able.", "community_id": 3, "creator_id": 8, "deleted": false, "embed_description": null, "embed_titl
e": null, "embed_video_url": null, "featured_community": true, "featured_local": true, "id": 452132, "language_id": 37, "local": true, "locked": false, "name": "welcome, new Beehaw users and lurkers. an FAQ and introduction to Beehaw", "nsfw
": false, "published": "2023-06-07T01:27:26.508415", "removed": false, "thumbnail_url": null, "updated": "2023-06-17T02:57:16.601841", "url": null}, "read": false, "saved": false, "subscribed": "NotSubscribed", "unread_comments": 217}

and here's the log for the post object from getPost:

LOG  {"community_view": {"blocked": false, "community": {"actor_id": "https://beehaw.org/c/support", "banner": "https://beehaw.org/pictrs/image/439dfc09-d740-4a9c-a03e-a41d627d342b.jpeg", "deleted": false, "description": "Support and meta c
ommunity for Beehaw. Ask your questions about the community, technical issues, and other such things here.

A brief FAQ for lurkers and new users can be found [here](https://beehaw.org/post/452132).

Our [June 2023 financial update is here](https://beehaw.org/post/428209).

For a refresher on our philosophy, see also [What is Beehaw?](https://beehaw.org/post/107014), [Beehaw is a Community](https://beehaw.org/post/140733), and [A few thoughts on Beehaw's design](https://beehaw.org/post/439918) ([second half](ht
tps://beehaw.org/comment/84235)).

---

This community's icon was made by Aaron Schneider, under the [CC-BY-NC-SA 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/).", "hidden": false, "icon": "https://beehaw.org/pictrs/image/b101eefc-9ec4-4c03-8913-78a4ebacd206.png"
, "id": 3, "instance_id": 664, "local": true, "name": "support", "nsfw": false, "posting_restricted_to_mods": false, "published": "2022-01-28T12:49:35.450320", "removed": false, "title": "Beehaw Support", "updated": "2023-06-15T17:01:56.3469
59"}, "counts": {"comments": 4227, "community_id": 3, "hot_rank": 0, "id": 2, "posts": 226, "published": "2022-01-28T12:49:35.450320", "subscribers": 1565, "users_active_day": 53, "users_active_half_year": 1341, "users_active_month": 1323, "
users_active_week": 926}, "subscribed": "NotSubscribed"}, "moderators": [{"community": [Object], "moderator": [Object]}, {"community": [Object], "moderator": [Object]}, {"community": [Object], "moderator": [Object]}, {"community": [Object],
"moderator": [Object]}, {"community": [Object], "moderator": [Object]}], "online": 3, "post_view": {"community": {"actor_id": "https://beehaw.org/c/support", "banner": "https://beehaw.org/pictrs/image/439dfc09-d740-4a9c-a03e-a41d627d342b.jpe
g", "deleted": false, "description": "Support and meta community for Beehaw. Ask your questions about the community, technical issues, and other such things here.

A brief FAQ for lurkers and new users can be found [here](https://beehaw.org/post/452132).

Our [June 2023 financial update is here](https://beehaw.org/post/428209).

For a refresher on our philosophy, see also [What is Beehaw?](https://beehaw.org/post/107014), [Beehaw is a Community](https://beehaw.org/post/140733), and [A few thoughts on Beehaw's design](https://beehaw.org/post/439918) ([second half](ht
tps://beehaw.org/comment/84235)).

---

This community's icon was made by Aaron Schneider, under the [CC-BY-NC-SA 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/).", "hidden": false, "icon": "https://beehaw.org/pictrs/image/b101eefc-9ec4-4c03-8913-78a4ebacd206.png"
, "id": 3, "instance_id": 664, "local": true, "name": "support", "nsfw": false, "posting_restricted_to_mods": false, "published": "2022-01-28T12:49:35.450320", "removed": false, "title": "Beehaw Support", "updated": "2023-06-15T17:01:56.3469
59"}, "counts": {"comments": 217, "downvotes": 0, "featured_community": true, "featured_local": true, "hot_rank": 1, "hot_rank_active": 1, "id": 40768, "newest_comment_time": "2023-06-19T12:31:55.208013", "newest_comment_time_necro": "2023-0
6-09T00:35:08.500367", "post_id": 452132, "published": "2023-06-07T01:27:26.508415", "score": 526, "upvotes": 526}, "creator": {"actor_id": "https://beehaw.org/u/alyaza", "admin": true, "avatar": "https://beehaw.org/pictrs/image/018439e1-9b4
d-4100-9ed1-78b4fa2cd68c.png", "ban_expires": null, "banned": false, "banner": "https://beehaw.org/pictrs/image/b508b38e-6171-4bd6-b736-ab68084c090b.png", "bio": "internet gryphon. admin of Beehaw, mostly publicly interacting with people. no
nbinary. they/she", "bot_account": false, "deleted": false, "display_name": "alyaza", "id": 8, "inbox_url": "https://beehaw.org/u/alyaza/inbox", "instance_id": 664, "local": true, "matrix_user_id": null, "name": "alyaza", "published": "2022-
01-28T22:43:09.245896", "shared_inbox_url": "https://beehaw.org/inbox", "updated": "2022-08-24T13:55:50.404458"}, "creator_banned_from_community": false, "creator_blocked": false, "my_vote": 1, "post": {"ap_id": "https://beehaw.org/post/4521
32", "body": "hey folks. here's a new FAQ on the community, since the currently pinned thread is a bit haphazard and crammed now, and we've had more time to go over stuff.

##### What is Beehaw?

in summary, we're a community that wants to cultivate a sense of real belonging to something, to foster meaningful conversations, and to ensure everyone feels valued and respected in a way that isn't the case with other social media out ther
e. we've thought and written a lot about this. if you'd like more than that summary, we strongly encourage you to read the following three essays, which explain how this community is run, what we priortize in running it, and why we've design
ed it this way generally:

* [What is Beehaw?](https://beehaw.org/post/107014)
* [Beehaw is a Community](https://beehaw.org/post/140733)
* [A few thoughts on Beehaw's design](https://beehaw.org/post/439918)

##### This sounds very cool! How do I join?

[you can register here](https://beehaw.org/signup).

**you don't need to write a whole essay, however: *please* answer the question fully, and try to engage with at least some of the content above/on the sidebar before you register.**

this is not personal, but we've grown a lot in the past week and are primarily interested in users who really care for the philosophy of our community. if you don't answer the question fully, you will likely get caught in registration limbo
(see below).

##### How long should I expect to wait to be approved?

**anywhere from a few minutes to a day. in general, try logging in after about 24 hours.**

if you haven't been approved within 24 hours your application is almost certainly in limbo because you didn't answer our entry question to our satisfaction. this doesn't mean we're rejecting you, per se, but it generally means we didn't thin
k you engaged with the content above/on the sidebar. **we *finally* have a hack solution to denials devised and automated, so as of now if you're a new registration you should eventually get a denial email (and have the username you chose wi
ped, so you can reapply with it). if you're in registration limbo you should also *eventually* get an email, although we have no idea how long it'll take to get.**

**if you *have* been approved and you used an email to sign up you should receive an email for that, although it might be marked as spam.** we're still trying to get Gmail to consistently take our emails, so again the 24 hour rule is best if
 you're unsure or haven't received one.

if you have issues of this sort, please [report them in the following thread](https://beehaw.org/post/448510)!

##### I'm in! How can I keep Beehaw running, or otherwise contribute?

our instance is 100% user-funded. you can one-time donate or become a monthly donor [here](https://opencollective.com/beehaw/donate). you can donate anonymously both ways. as far as we're aware cryptocurrency [is accepted by OpenCollective](
as for non-moderation ways you can keep things running: contribute to discussions! share stuff you find interesting! contribute your expertise and help out folks when they ask for it! it's okay—and very understandable—to lurk based on the toxicity commonp
lace on other social media, but we really do try to make this space as welcoming as possible to everyone here and we hope you'll find it a safer place to come out of your online shell.

##### What else should I know?

we always take feedback. while we can't *promise* any changes, you can provide thoughts and comments on just about anything on the site in Beehaw Support, or on Discord or Matrix (where we maintain real-time chat). we try to get a sense of what the commun
ity wants and needs all the time, so we'll frequently be asking for input from you to help inform our decisions.

[downvotes are disabled on this instance and will probably always be](https://beehaw.org/comment/29314). we find them unproductive. [communities cannot be made by users on here](https://beehaw.org/post/140733). we do take feedback on what gets made and wh
en to make communities, as a part of the above point. you can always find a running list of communities we have [at this link](https://beehaw.org/communities), or under the Communities button on desktop.

we are all volunteers, and this is not a job for us. we would like to not have it be one, so we can just be members of the community with all of you. please help keep it that way!

in the very, very long term, [we aspire to become a co-op or similar](https://beehaw.org/comment/67350), as a part of fulfilling our ethos.

as with the last thread, feel free to sound off on other questions you have. i, other mods, and community members will try to get to them as able.", "community_id": 3, "creator_id": 8, "deleted": false, "embed_description": null, "embed_title": null, "emb
ed_video_url": null, "featured_community": true, "featured_local": true, "id": 452132, "language_id": 37, "local": true, "locked": false, "name": "welcome, new Beehaw users and lurkers. an FAQ and introduction to Beehaw", "nsfw": false, "published": "2023
-06-07T01:27:26.508415", "removed": false, "thumbnail_url": null, "updated": "2023-06-17T02:57:16.601841", "url": null}, "read": true, "saved": false, "subscribed": "NotSubscribed", "unread_comments": 0}}

Version

BE: 0.17.4

Lemmy Instance URL

beehaw.org

JPMoresmau commented 1 year ago

My initial testing on the backend didn't show the bug (see https://github.com/LemmyNet/lemmy/pull/3215), so maybe there's something happening between the frontend and the backend?

brunofin commented 1 year ago

Thanks, I will do a Postman request later to double check, if it does come back correctly then I am afraid the issue must be in the JS library

dessalines commented 1 year ago

Stale

Nutomic commented 1 year ago

I can confirm this, PostView includes my_vote only if you use /api/v3/post. Using /api/v3/post/list the field is missing. Looks like a bug in the db query.

brunofin commented 1 year ago

This is great! Will save my client from making many unneeded requests now, can't wait for this to go online! Thank you!

On Mon, 23 Oct 2023, 6:40 pm Dessalines, @.***> wrote:

Closed #3197 https://github.com/LemmyNet/lemmy/issues/3197 as completed via 5bfa4e9 https://github.com/LemmyNet/lemmy/commit/5bfa4e9358cb10dc9e93d0dbdfca57b501a9a529 .

— Reply to this email directly, view it on GitHub https://github.com/LemmyNet/lemmy/issues/3197#event-10743459077, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5T7NNBHCNAT4K3ERVUGYDYA2MYZAVCNFSM6AAAAAAZL4647OVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQG42DGNBVHEYDONY . You are receiving this because you authored the thread.Message ID: @.***>