Fix sent follow request detection #2177

Closed
rinpatch wants to merge 0 commits from gitlab-mr-iid-910 into develop
Member

This fixes requestFollow using the relationship instead of user object,
resulting in sent always being false for locked users, and also removes
assumptions about follow request being sent, instead relying on
requested from user relationship.

This fixes `requestFollow` using the relationship instead of user object, resulting in `sent` always being false for locked users, and also removes assumptions about follow request being sent, instead relying on `requested` from user relationship.
Member

probably should stop retrying if we know that user is locked and we've sent the request?

although IIRC remote user can lock themselves and BE wouldn't know it just yet so it will still work like "request sent"

probably should stop retrying if we know that user is locked and we've sent the request? although IIRC remote user can lock themselves and BE wouldn't know it just yet so it will still work like "request sent"
Member

probably should be something like sent || following but i'm not sure how requested works actually

probably should be something like `sent || following` but i'm not sure how `requested` works actually
Author
Member

requested becomes false when the follow is approved

`requested` becomes false when the follow is approved
Author
Member

It won't start refetching the user if it is locked, see #2177/diffs

It won't start refetching the user if it is locked, see https://git.pleroma.social/pleroma/pleroma-fe/pulls/2177/diffs#20c41b74f87ed662c61e1ca4fa01fa3ba329b441_32_24
Member

it does right here, see line 12 in this very file - if we're not following user yet it will call function recursively until we run out of attempts.

it does right here, see line 12 in this very file - if we're not following user yet it will call function recursively until we run out of attempts.
Member

good opportunity to add a return after this line so that we exit the function and not refetch the user needlessly

good opportunity to add a `return` after this line so that we exit the function and not refetch the user needlessly
Author
Member

like this?

like this?
Member

i mean the outcome of the function is - determine if we're following the user or at least we sent a follow request. Up until now we couldn't know if we sent a follow request instead of following, so we just assumed that if we are still not following user after several re-fetches (since BE does not update it right away sometimes) it means we sent a follow request. If we can know that we sent a follow request right away it would be incredibly helpful.

The thing is here, if i'm remembering correctly, that depending of outcome here FE will either display "Following!" (for true) or "Follow request sent!" (for false) so it should probably stay as return following here

i mean the outcome of the function is - determine if we're following the user or at least we sent a follow request. Up until now we couldn't know if we sent a follow request instead of following, so we just assumed that if we are still not following user after several re-fetches (since BE does not update it right away sometimes) it means we sent a follow request. If we can know that we sent a follow request right away it would be incredibly helpful. The thing is here, if i'm remembering correctly, that depending of outcome here FE will either display "Following!" (for true) or "Follow request sent!" (for false) so it should probably stay as `return following` here
Member

will be kinda broken for case when

  1. remote user becomes locked
  2. backend doesn't know about it yet
  3. we try to follow them, FE and BE believe that user is not locked
  4. it will keep retrying until we either run out of attempts or realize user is locked

what I'm thinking about is

if (!following && !sent && attempts <= 3)

will be kinda broken for case when 1. remote user becomes locked 2. backend doesn't know about it yet 3. we try to follow them, FE and BE believe that user is not locked 4. it will keep retrying until we either run out of attempts or realize user is locked what I'm thinking about is `if (!following && !sent && attempts <= 3)`
Member

not quite

not quite
Member

would probably be great to actually make it show "Request sent" in UI based on that field, since right now it will reset from navigating away from the page

would probably be great to actually make it show "Request sent" in UI based on that field, since right now it will reset from navigating away from the page
Member
          resolve({ sent })
```suggestion:-0+0 resolve({ sent }) ```
Author
Member

The thing is here, if i'm remembering correctly, that depending of outcome here FE will either display "Following!" (for true) or "Follow request sent!" (for false)

No, it will show "Follow Request Sent" when sent: true and user.following: false

> The thing is here, if i'm remembering correctly, that depending of outcome here FE will either display "Following!" (for true) or "Follow request sent!" (for false) No, it will show "Follow Request Sent" when sent: true and user.following: false
Author
Member

sent will be true for non-locked users as well, if the backend didn't yet recieve an approval from the remote server

`sent` will be true for non-locked users as well, if the backend didn't yet recieve an approval from the remote server
Member

now that's what i call useless

now that's what i call useless
Member

yeah it can remain as is then

i guess i expected too much

yeah it can remain as is then i guess i expected too much
Member

ok no, this still can be improved i believe, let me formalize it

ok no, this still can be improved i believe, let me formalize it
Member

since we have the info now it would make sense to only really confirm that we've sent the request when we actually know it

      if (updated.following || (user.locked && user.requested)) {
since we have the info now it would make sense to only really confirm that we've sent the request when we actually know it ```suggestion:-0+0 if (updated.following || (user.locked && user.requested)) { ```
Member
  if (!following && !(locked && sent) && attempt <= 3) {
```suggestion:-0+0 if (!following && !(locked && sent) && attempt <= 3) { ```
Member

LGTM, if you want, displaying the "request sent" could be done in a separate MR, just make an issue about it.

LGTM, if you want, displaying the "request sent" could be done in a separate MR, just make an issue about it.
Author
Member

Opened #635

Opened #635
Member

if anything breaks i'm gonna fix it myself - that code needs more comments anyway

if anything breaks i'm gonna fix it myself - that code needs more comments anyway

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/pleroma-fe!2177
No description provided.