Transition to MastoAPI: user data #1925

Closed
hj wants to merge 0 commits from gitlab-mr-iid-655 into develop
Owner
  • Added support for fetching relationship via API.
  • Made code more resilient to missing data - mergeOrAdd now completely ignores null values.
  • Optimized some things that were doing same thing twice, sometimes badly.
  • Fetches user posts and user media via MastoAPI
- Added support for fetching relationship via API. - Made code more resilient to missing data - mergeOrAdd now completely ignores `null` values. - Optimized some things that were doing same thing twice, sometimes badly. - Fetches user posts and user media via MastoAPI
Owner

don't like this rename, it's not a find so why call it a find? userById tells exactly what it returns and using what data

don't like this rename, it's not a find so why call it a find? userById tells exactly what it returns and using what data
Owner

skip

skip
Owner

would prefer filter instead of reject/omit when possible, and when working with objects, filter with identity func would work just as well

would prefer filter instead of reject/omit when possible, and when working with objects, filter with identity func would work just as well
Owner

'used'

'used'
Owner

unused args, also I can't say for sure but I have a feeling that we might run into bugs here, this part has been bug prone and now it works differently again

unused args, also I can't say for sure but I have a feeling that we might run into bugs here, this part has been bug prone and now it works differently again
Owner

iid?

iid?
Author
Owner

yeah, this test basically needs a rewrite i think, i'll look into it.

yeah, this test basically needs a rewrite i think, i'll look into it.
Author
Owner

sure

sure
Author
Owner

whoops

whoops
Author
Owner

yeah, the whole user profile might as well changed somewhat. A lot of trouble comes from the whole id/name discrepancy. I'll remove unused bugs.

yeah, the whole user profile might as well changed somewhat. A lot of trouble comes from the whole id/name discrepancy. I'll remove unused bugs.
Author
Owner

whoops

whoops
Author
Owner

the thing is, userById and userByName been doing nearly same thing except using worse way (iterating over array instead of using a map), Since we store users both by screen name (locals only) and by id (everyone) the only thing we're missing here is case insensitivity, though that could be fixed easily.

the thing is, `userById` and `userByName` been doing nearly same thing except using worse way (iterating over array instead of using a map), Since we store users both by screen name (locals only) and by id (everyone) the only thing we're missing here is case insensitivity, though that could be fixed easily.
Author
Owner

Well... since it's an object, the alternative is...

      Object.entries(item)
        .filter(([k, v]) => v !== null)
        .reduce((acc, [k, v]) => {
          acc[k] = v
          return acc
        }, {}))

as much as i don't like using lodash, you can't do just {}.filter([k,v] => ...)

Well... since it's an object, the alternative is... ```js Object.entries(item) .filter(([k, v]) => v !== null) .reduce((acc, [k, v]) => { acc[k] = v return acc }, {})) ``` as much as i don't like using lodash, you can't do just `{}.filter([k,v] => ...)`
Author
Owner

actually much easier than i thought

actually much easier than i thought
Author
Owner

i've made it case insensitive by downcasting all the time.

i'm open for suggestions for a better name. It searches usersObject if there's a user with needed screen name (only used for local users, so we can query the object as well) or id

i've made it case insensitive by downcasting all the time. i'm open for suggestions for a better name. It searches `usersObject` if there's a user with needed screen name (only used for local users, so we can query the object as well) or id
Owner

ah nevermind that then, I misunderstood what the original did

now I'm just confused why are we omitting any props from anything? seems pretty useless

ah nevermind that then, I misunderstood what the original did now I'm just confused why are we omitting any props from anything? seems pretty useless
Owner

oh it does both now? do we have a map of users with ids and names in the keys now? that's a bit confusing but ok

oh it does both now? do we have a map of users with ids and names in the keys now? that's a bit confusing but ok
Author
Owner

It did for a long while, only storing local users this way though.

It did for a long while, only storing local users this way though.
Author
Owner

This is for better compatibility with normalizer and inconsistent data, really. Though there is another way, at least i see it now.

This is the place where we update our user and, in other place, status is updated similar way. The problem is, if you had object like { a: 1 } and merge { a: null } into it it will become { a: null } which basically removes existing data and often causes things to "blink".

Another option would be getting rid of the nulls, which is replacing following: null //missing in MastoAPI with //following (missing in MastoAPI) and so on.

This is for better compatibility with normalizer and inconsistent data, really. Though there is another way, at least i see it now. This is the place where we update our user and, in other place, status is updated similar way. The problem is, if you had object like `{ a: 1 }` and merge `{ a: null }` into it it will become `{ a: null }` which basically removes existing data and often causes things to "blink". Another option would be getting rid of the nulls, which is replacing `following: null //missing in MastoAPI` with `//following (missing in MastoAPI)` and so on.
Author
Owner

i think I'll do just that instead.

i think I'll do just that instead.
https://git.pleroma.social/pleroma/pleroma/pulls/4308

looks fine overall but readability could profit a lot from using async / await instead of promise chains.

looks fine overall but readability could profit a lot from using async / await instead of promise chains.
Author
Owner

Yeah, i'm just not entirely used to async/await just yet. I hope you're ok with this MR not getting a refactor for it.

Yeah, i'm just not entirely used to async/await just yet. I hope you're ok with this MR not getting a refactor for it.
Author
Owner

Once that's merged it I can test it and then update it. As we all know this spot is very bug-prone already so I really don't want to do blind fixes there - much more work.

Once that's merged it I can test it and then update it. As we all know this spot is very bug-prone already so I really don't want to do blind fixes there - much more work.
Author
Owner

i did it.

i did it.

sure, we can refactor lator.

sure, we can refactor lator.
Member

property names under relationship are slightly different.

  • relationship.follows_you => relationship.followed_by
  • relationship.statusnet_blocking => relationship.blocking
  • relationship.muted => relationship.muting

also, we need to support the following property.

output.following => relationship.following

property names under `relationship` are slightly different. - `relationship.follows_you` => `relationship.followed_by` - `relationship.statusnet_blocking` => `relationship.blocking` - `relationship.muted` => `relationship.muting` also, we need to support the `following` property. `output.following` => `relationship.following`
Author
Owner

thanks, i sorta gave up on this part since it was my suggestion to add this exact block temporarily until we add /relationships support... which this MR adds since BE's MR didn't work for me initially.

thanks, i sorta gave up on this part since it was my suggestion to add this exact block temporarily until we add `/relationships` support... which this MR adds since BE's MR didn't work for me initially.

So what is missing to get this in? everything else is depending on it.

So what is missing to get this in? everything else is depending on it.
Author
Owner

Nothing, i was mostly just testing it. Luckily i did find some bugs and fixed them.

Nothing, i was mostly just testing it. Luckily i did find some bugs and fixed them.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!1925
No description provided.