Transition to MastoAPI: user data #1925

Closed
hj wants to merge 0 commits from gitlab-mr-iid-655 into develop
Member
  • 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
Member

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
Member

skip

skip
Member

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
Member

'used'

'used'
Member

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
Member

iid?

iid?
Author
Member

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
Member

sure

sure
Author
Member

whoops

whoops
Author
Member

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
Member

whoops

whoops
Author
Member

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
Member

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
Member

actually much easier than i thought

actually much easier than i thought
Author
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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.