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
405 stars 63 forks source link

feat: author entity props blocking #186

Closed CodeVoyager closed 1 year ago

CodeVoyager commented 1 year ago

Ticket

https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/issues/183

Summary

What does this PR do/solve?

Test Plan

codecov-commenter commented 1 year ago

Codecov Report

Merging #186 (3c41b33) into develop (890d348) will increase coverage by 0.04%. The diff coverage is 86.95%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           develop     #186      +/-   ##
===========================================
+ Coverage    79.36%   79.41%   +0.04%     
===========================================
  Files           34       34              
  Lines          882      889       +7     
  Branches       292      292              
===========================================
+ Hits           700      706       +6     
  Misses         179      179              
- Partials         3        4       +1     
Flag Coverage Δ
unittest 79.41% <86.95%> (+0.04%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/utils/constants.ts 100.00% <ø> (ø)
server/services/utils/functions.ts 82.27% <66.66%> (+0.22%) :arrow_up:
server/services/common.ts 79.42% <77.77%> (-0.23%) :arrow_down:
server/services/admin.ts 76.59% <100.00%> (ø)
server/services/client.ts 85.81% <100.00%> (+0.29%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Jahorse commented 1 year ago

I tried pulling the PR locally and building it into my website. I added blockedAuthorProps: ['email'], to my plugins.js file, but I can still see the email field on the front end.

When debugging the code, I see it isn't finding the blockedAuthorProps key in my config. It looks like it's only finding the config values I have set inside my admin panel and skipping the local config. This seems to be happening because the useLocal parameter defaults to false here: https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/blob/master/server/services/common.ts#L61. When I override this value to true I am able to get the functionality I expect, the email field is not returned.

cyp3rius commented 1 year ago

@Jahorse keep in mind that as plugin supports the Settings page, plugins.js is a default state and after that all is stored in the Strapi DB. To make it working you must first "Restore" settings on the Settings page to make them be pulled from the file.

Jahorse commented 1 year ago

@cyp3rius I did use the restore feature after setting the new config field. Is this new field integrated with that restore functionality properly? It didn't seem to do anything for me. If I get time later I'll try to run a restore through the debugger to confirm.

CodeVoyager commented 1 year ago

I added a new input for the settings page. From now on you don't need to put settings in the file.

Jahorse commented 1 year ago

I pulled in the latest updates and everything is working great! I was able to use the reset button from the admin panel and it reset the blocked props field to the value from my plugins config. Calling the comments plugin API from my frontend did not return the email field.