Closed karlmoubarak closed 2 years ago
Hi @karlmoubarak . I've had the same issue as you. TL;DR; insert in your database, up_permissions table the permission "plugin::mux-video-uploader.mux-asset.find", then insert into the table "up_permissions_role_links" the id's for the role/permission you just added, then ensure you have it checked in the strapi admin under "USERS & PERMISSIONS PLUGIN > Roles > Mux-video-uploader" (this is shown only after you insert the permission in the table above.
Long answer: The plugin should probably insert these permissions in the DB itself when first installed. The populate doesn't work otherwise, as told by the strapi docs here: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/populating-fields.html#population
"If the users-permissions plugin is installed, the find permission must be enabled for the content-types that are being populated. If a role doesn't have access to a content-type it will not be populated."
Hey @karlmoubarak and @andreigabreanu, Thanks for this conversation. I agree with @andreigabreanu. We should actually set this permission as settable within the plugin. We'll work through exposing this in the user's permissions page. In the meantime, Andrei's workaround sounds like it'll work.
Exactly the same here. Just add that this happend also with graphql endpoint with admin credentials (not tested with user-permission users yet)
Thank you all for your help <3
Had same issue, glad to see that this is being addressed but for now will use @andreigabreanu work around.
Hey @karlmoubarak and @andreigabreanu, Thanks for this conversation. I agree with @andreigabreanu. We should actually set this permission as settable within the plugin. We'll work through exposing this in the user's permissions page. In the meantime, Andrei's workaround sounds like it'll work.
I agree as well. Wanted to make a tutorial on how to set up MUX plugin with Strapi but I feel that for users that may not be familiar with how to insert data into DB manually will add unnecessary friction witch may prevent them taking the extra step and using MUX as a service. Especially for someone like me, who is more of a frontend developer.
Looking forwards to the update.🙂
@andreigabreanu I am facing the same issue the mux asset values are not getting returned in the find and findone api. Does the plugin still have the issue and do we need to make DB changes manually?
I have added mux_video_uploader_mux_asset: { populate: “2A” } in findone but did not get any data related to mux data.
Kindly suggest
This is now resolved in the latest release of 2.4.0 which included some updates to the permission system between the plugin and Strapi.
Creating a basic collection type that has a relationship to the mux-asset, I was able to perform a query for a list of entries—
curl --location -g --request GET 'http://localhost:1337/api/videos?populate[0]=mux_asset'
--header 'Authorization: Bearer REDACTED'
and receive the following response with the populated mux_asset
relation field—
{
"data": [
{
"id": 1,
"attributes": {
"title": "Test",
"description": null,
"createdAt": "2022-11-18T06:03:49.314Z",
"updatedAt": "2022-11-19T05:24:11.975Z",
"publishedAt": "2022-11-19T05:24:11.972Z",
"mux_asset": {
"data": {
"id": 2,
"attributes": {
"title": "Test",
"upload_id": "63ZdvqJqVfM2YRH00x67ASpoK01MIvbMKwHkwy8Vl01ni8",
"asset_id": "kLv4w4XyRipV1yvAhbXeuvfYxs01V9o8UITLNRSucw00s",
"playback_id": "00mqfFvCGH1oKqdhYIM2vaSVZItLeHxh1R02cMNwse00SE",
"error_message": null,
"isReady": true,
"duration": 300.75,
"aspect_ratio": "16:9",
"createdAt": "2022-11-18T05:08:08.524Z",
"updatedAt": "2022-11-18T05:09:52.441Z"
}
}
}
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 1
}
}
}
heyo, thanks for this great work. It's helped a lot.
I'm buillding an api for some livestream events and using assets uploaded with the mux video uploader in a relational field for each event. Event is a collection type.
When i use the strapi rest API to findone event and populate it's 'recording' field, everything works as expected:
/api/events/dfdfg?populate[0]=messages&populate[1]=recording
( here i am replacing the findOne controller with a custom one to use slugs instead of ids. But this shouldn't affect population since params are passed on normally ).However, when i use the rest API to findmany events and populate the 'recording' field, it doesn't work:
api/events?populate[0]=messages&populate[1]=recording
I was thinking of posting this issue to strapi but it looks like populating works for all other fields (as you can see with 'messages' field).
Is it because of the type of relation? Am I missing something? Maybe I did something wrong?