Get comments endpoint doesn't filter by author
ubaranzorlu opened this issue · 2 comments
ubaranzorlu commented
Summary
I expect get comments endpoint to be able to filter author or author.id property according to Strapi Docs. However, it throws an error.
Steps to reproduce
- Make a comment
- Send GET request to "/api/comments/{collection}:{id}/flat?pagination[pageSize]=5&pagination[page]=1&pagination[withCount]=true&filters[author][$eq]=58&sort=createdAt:desc"
Expected results
Return comments sent by the author specified (58).
Actual results
{
"data": null,
"error": {
"status": 500,
"name": "InternalServerError",
"message": "Internal Server Error"
}
}
I have tried other filter queries as well with no luck.
- &filters[author][$eq]=58
- &filters[author.id][$eq]=58
- &filters[author_id][$eq]=58 <- returns a regular response with blank array, not error
- &filters[user_id][$eq]=58
cyp3rius commented
Hello @ubaranzorlu,
as the plugin support both non-Strapi + Strapi users the filtering should be done like below.
non-Strapi users:
/api/comments/api::page.page:1/flat?filters[authorId]=123456
/api/comments/api::page.page:1/flat?filters[authorEmail]=test@example.com
/api/comments/api::page.page:1/flat?filters[authorName]=Joe
Strapi users:
/api/comments/api::page.page:1/flat?filters[authorUser]=1
ubaranzorlu commented
Thanks for your response, it worked. Adding this info to the Readme might be helpful for others.