VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
410 stars 64 forks source link

No Strapi User issue #16

Closed IsabelDD closed 3 years ago

IsabelDD commented 3 years ago

I can create a comment by a no strapi user correctly, like in the example below and the comment appears on the article, but when I do a Get call I only get comments from Strapi users.

image image image

cyp3rius commented 3 years ago

@IsabelDD for getting comments per specified content type there is a dedicated endpoint: https://github.com/VirtusLab/strapi-plugin-comments#get-comments

The default Content Manager endpoints are not supporting all the features of Comments plugin. We suggest you to use the delivered and tested endpoints rather than CM. Of course you can try to modify the Article API to pull properly the polymorphic relations, but it might be a bigger case and might change in future versions of plugin and Strapi.

IsabelDD commented 3 years ago

Yes, I know, the correct way of get the comments if via the get-comments. But my issue is that the comments create by a no strapi user, doesn't appear on this call. Only I can see the comments related to a Strapi User. I would like to know the reason of this.

cyp3rius commented 3 years ago

@IsabelDD I've checked your payloads and I think I've found what you've been doing wrong. Check the POST request you're triggering. There is threadOf: 0, based Readme.md you've to use the id of comment that you're responding to. Otherwise, as mentioned this parameter is optional so use null or just drop it from request to post a direct response to your Content / Article.

The payload from /articles/1 shows all comments related to the Article by default as all of them are indeed related to your article. Using our endpoint comments/article/1 you're getting just a root comment with id 35. Other comments are dropped, because you've set them threadOf: 0 and there is no possibility to find a match in scope of Article:1. Behavior is correct.

What I can suggest:

  1. Change the threadOf to proper value or null fix the relation
  2. Recreate comments

This is not related to strapi / non-strapi user at all. Hope my explanation helps.