Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CU-2cq60k0] Maybe populate the author field? #113

Closed
be90728 opened this issue Feb 17, 2022 · 12 comments
Closed

[CU-2cq60k0] Maybe populate the author field? #113

be90728 opened this issue Feb 17, 2022 · 12 comments
Assignees
Labels
backlog enhancement New feature or request solved Issue has been solved v4 Strapi v4

Comments

@be90728
Copy link

be90728 commented Feb 17, 2022

When the comment author is a registered strapi user
For example, I populate authorUser.role, but the field role will be cleared because of buildAuthorModel in sanitizeCommentEntity.

Maybe we can add an author populate field to the plugin configuration page?
In this way, there is no need to worry about the leakage of the author's confidential information due to illegal query populate.

@cyp3rius
Copy link
Collaborator

Hello @be90728 ,

That kind of request pops up already for v3 (in terms of avatar). We're going to consider extending support for fields population, the real challenge will be to do this on UI by easy to understand way ;)

@cyp3rius cyp3rius self-assigned this Feb 20, 2022
@cyp3rius cyp3rius added enhancement New feature or request v4 Strapi v4 backlog labels Feb 20, 2022
cyp3rius added a commit that referenced this issue Apr 15, 2022
cyp3rius added a commit that referenced this issue Apr 21, 2022
@cyp3rius cyp3rius changed the title Maybe populate the author field? [CU-2cq60k0] Maybe populate the author field? Apr 22, 2022
cyp3rius added a commit that referenced this issue Apr 22, 2022
* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* chore: bump strapi-typed version
cyp3rius added a commit that referenced this issue Apr 22, 2022
* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* feat: issue #115 support rest select fields in query

* chore: client api service tests coverage

* fix: conflicts resolution

* fix: small some tests fixes
cyp3rius added a commit that referenced this issue Apr 22, 2022
* Feat/typescript (#123)

* Feat: add pt-BR translation (#119)

* feat: add pt-br translation

* refac: add missing key

* fix: approved translation

* chore: version bump

* feat: typescript flow and basic typings

* feat: ts-jest and tests

* feat: client service to typescript

* feat: types functions utils

* fix: runtime errors

* feat: usage of strapi-typed package and coverage for services

* chore: strapi-typed version bump

* feat: initial ts move done

* chore: prettier formatting

* moved types out to strapi-typed

* fix: fixing pluginId importing

* Update server/services/utils/functions.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update server/services/utils/functions.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update strapi-server.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update types/config.d.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update types/controllers.d.ts

Co-authored-by: Tomasz Puch <[email protected]>

* refactor: reworks after review

* refactor: last reworks

* refactor: prettier formatting

Co-authored-by: Rafael Faria <[email protected]>
Co-authored-by: Tomasz Puch <[email protected]>

* chore: version bump

* fix: package.json outdated

* feat: typescripted client service and controllers

* Feat/rest fields query (#132)

* feat: issue #115 support rest select fields in query

* chore: bump strapi-typed to 1.0.8

* refactor: reworks based on pr comments

* refactor: typings alignments based on pr review

* [CU-2cq60k0] feat: issue #113 author field population (#133)

* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* chore: bump strapi-typed version

* [CU-2cq6299] chore/api service client tests (#134)

* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* feat: issue #115 support rest select fields in query

* chore: client api service tests coverage

* fix: conflicts resolution

* fix: small some tests fixes

* refactor: prettier formatting

Co-authored-by: Rafael Faria <[email protected]>
Co-authored-by: Tomasz Puch <[email protected]>
@cyp3rius
Copy link
Collaborator

Released as part of 2.1.0

@cyp3rius cyp3rius added solved Issue has been solved and removed in progress labels Apr 22, 2022
@Tragio
Copy link
Contributor

Tragio commented Apr 24, 2022

@cyp3rius thank you for your awesome work. 🙏 I wonder would be the right way to add the avatar field 🤔

Shouldn't be like this to populate the avatar field?
/api/comments/api::test:test:40/flat?populate[authorUser][populate][0]=avatar

@cyp3rius
Copy link
Collaborator

cyp3rius commented Apr 25, 2022

@Tragio yep that's the correct way to do this. Both examples should work:

/api/comments/api::page.page:1/flat?populate[authorUser][populate][0]=avatar
/api/comments/api::page.page:1/flat?populate[author][populate][0]=avatar

I got following result in one of my queries:

{
"id": 10,
"content": "Fusce bibendum molestie scelerisque.",
"blocked": false,
"blockedThread": false,
"blockReason": null,
"removed": null,
"approvalStatus": null,
"related":{"id": 1, "Title": "ghghghgh", "Content": null, "createdAt": "2022-03-30T20:54:53.162Z",},
"createdAt": "2022-04-15T11:26:29.897Z",
"updatedAt": "2022-04-15T11:26:29.897Z",
"threadOf": null,
"gotThread": false,
"author":{
  "id": 1,
  "name": "Test",
  "email": "[email protected]",
  "avatar":{
    "id": 1,
    "name": "Hand-Drawn-Blue-Bird-Avatar.jpeg",
    "alternativeText": "Hand-Drawn-Blue-Bird-Avatar.jpeg",
    "caption": "Hand-Drawn-Blue-Bird-Avatar.jpeg",
    "width": 480,
    "height": 480,
    "formats":{"thumbnail":{"ext": ".jpeg", "url": "/uploads/thumbnail_Hand_Drawn_Blue_Bird_Avatar_c9c6d8cc2b.jpeg",},
    "hash": "Hand_Drawn_Blue_Bird_Avatar_c9c6d8cc2b",
    "ext": ".jpeg",
    "mime": "image/jpeg",
    "size": 15.13,
    "url": "/uploads/Hand_Drawn_Blue_Bird_Avatar_c9c6d8cc2b.jpeg",
    "previewUrl": null,
    "provider": "local",
    "provider_metadata": null,
    "createdAt": "2022-04-15T11:51:04.979Z",
    "updatedAt": "2022-04-15T11:51:04.979Z"
  }
}
}

@Tragio
Copy link
Contributor

Tragio commented Apr 25, 2022

@cyp3rius hmmm strange that it was not working. I updated to version 2.1.2 to see if that was fixed but the plugin now stopped showing in the dashboard and the routes also give 404.

CleanShot 2022-04-25 at 09 48 51@2x

@cyp3rius
Copy link
Collaborator

cyp3rius commented Apr 25, 2022

in 2.1.1 there was fixed multiple fields population (the avatar was working without it)

Have you re-builded your admin tool?

@cyp3rius
Copy link
Collaborator

@Tragio found it, some files failed to transpile while publish. Fixed that and v2.1.3 got all in place.

@Tragio
Copy link
Contributor

Tragio commented Apr 25, 2022

@cyp3rius with 2.1.3 is giving critical error:

[2022-04-25 09:38:09] yarn run v1.22.18
[2022-04-25 09:38:09] $ strapi start
[2022-04-25 09:38:16] [2022-04-25 09:38:16.293] debug: ⛔️ Server wasn't able to start properly.
[2022-04-25 09:38:16] [2022-04-25 09:38:16.297] error: Could not load js config file /app/node_modules/strapi-plugin-comments/strapi-server.js: Cannot find module 'nexus'
[2022-04-25 09:38:16] Require stack:
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/services/graphql.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/services/index.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/index.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/strapi-server.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/config-loader.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/index.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/Strapi.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/index.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/commands/start.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/bin/strapi.js
[2022-04-25 09:38:16] Error: Could not load js config file /app/node_modules/strapi-plugin-comments/strapi-server.js: Cannot find module 'nexus'
[2022-04-25 09:38:16] Require stack:
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/services/graphql.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/services/index.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/server/index.js
[2022-04-25 09:38:16] - /app/node_modules/strapi-plugin-comments/strapi-server.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/config-loader.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/core/app-configuration/index.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/Strapi.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/index.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/lib/commands/start.js
[2022-04-25 09:38:16] - /app/node_modules/@strapi/strapi/bin/strapi.js
[2022-04-25 09:38:16]     at loadJsFile (/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:18:11)
[2022-04-25 09:38:16]     at loadFile (/app/node_modules/@strapi/strapi/lib/core/app-configuration/load-config-file.js:35:14)
[2022-04-25 09:38:16]     at Object.loadPlugins (/app/node_modules/@strapi/strapi/lib/core/loaders/plugins/index.js:96:26)
[2022-04-25 09:38:16]     at async Strapi.loadPlugins (/app/node_modules/@strapi/strapi/lib/Strapi.js:284:5)
[2022-04-25 09:38:16]     at async Promise.all (index 1)
[2022-04-25 09:38:16]     at async Strapi.register (/app/node_modules/@strapi/strapi/lib/Strapi.js:316:5)
[2022-04-25 09:38:16]     at async Strapi.load (/app/node_modules/@strapi/strapi/lib/Strapi.js:414:5)
[2022-04-25 09:38:16]     at async Strapi.start (/app/node_modules/@strapi/strapi/lib/Strapi.js:163:9)
[2022-04-25 09:38:16] error Command failed with exit code 1.
[2022-04-25 09:38:16] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@cyp3rius
Copy link
Collaborator

cyp3rius commented Apr 25, 2022

There was a mess with dependencies seems, I've done some more deep checks and reverted to the same package.json as for 2.1.0 in the new 2.1.4. Issue #136 got different background.

@Tragio
Copy link
Contributor

Tragio commented Apr 26, 2022

@cyp3rius so fresh morning, fresh mind. I forgot the avatar was created by me and not as default by Strapi, so it's called thumbnail and not avatar 🤦‍♂️ sorry for wasting your time, and really thank you for your support and awesome work!!

@cyp3rius
Copy link
Collaborator

No worries :D You've pushed me to double check the logic and define most strict tests and found the error with multiple fields population which has been solved already ;)

@kwiat1990
Copy link
Contributor

kwiat1990 commented May 6, 2022

Hey, I don't quite understand how avatar field is populated? The default user collection type doesn't have this field. And what I'm looking for is to have only url string for avatar as my user are created using social providers. Is it currently possible?

cyp3rius added a commit that referenced this issue Oct 12, 2022
* Feat/typescript (#123)

* Feat: add pt-BR translation (#119)

* feat: add pt-br translation

* refac: add missing key

* fix: approved translation

* chore: version bump

* feat: typescript flow and basic typings

* feat: ts-jest and tests

* feat: client service to typescript

* feat: types functions utils

* fix: runtime errors

* feat: usage of strapi-typed package and coverage for services

* chore: strapi-typed version bump

* feat: initial ts move done

* chore: prettier formatting

* moved types out to strapi-typed

* fix: fixing pluginId importing

* Update server/services/utils/functions.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update server/services/utils/functions.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update strapi-server.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update types/config.d.ts

Co-authored-by: Tomasz Puch <[email protected]>

* Update types/controllers.d.ts

Co-authored-by: Tomasz Puch <[email protected]>

* refactor: reworks after review

* refactor: last reworks

* refactor: prettier formatting

Co-authored-by: Rafael Faria <[email protected]>
Co-authored-by: Tomasz Puch <[email protected]>

* chore: version bump

* fix: package.json outdated

* feat: typescripted client service and controllers

* Feat/rest fields query (#132)

* feat: issue #115 support rest select fields in query

* chore: bump strapi-typed to 1.0.8

* refactor: reworks based on pr comments

* refactor: typings alignments based on pr review

* [CU-2cq60k0] feat: issue #113 author field population (#133)

* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* chore: bump strapi-typed version

* [CU-2cq6299] chore/api service client tests (#134)

* feat: issue #115 support rest select fields in query

* feat: issue #113 author field population

* refactor: reworks after pr review

* feat: issue #115 support rest select fields in query

* chore: client api service tests coverage

* fix: conflicts resolution

* fix: small some tests fixes

* refactor: prettier formatting

* feat: create reports page [CU-20rfmkv] (#153)

* feat: reports page

* refactor: changes after code review

* Feat/moderator responses in threads (#150)

* feat: Change WYSIWYG to TypeScript

* feat: Moderator response under thread

* feat: Delete comment

* feat: New comment notifications and standardize of refresh

* feat: Update and StartThread functionality

* fix: Blocking thread and comment of reported comment

* refactor: reworks after review

* refactor: reworks after further reviews

* Merge branch 'develop' into feat/moderator-responses-in-threads

Co-authored-by: Kamil Szewczyk <[email protected]>

* chore: version bump

* fix: fixes after merge

* feat: comments custom field [CU-2tn2923] (#157)

* feat: comments custom field

* chore: code coverage

* fix: pr feedback and tests

* chore: tests rename

* fix: failing test

* chore: version update

* feat: custom field icon

* fix: failing tests

* fix: typescript build failing

* fix: add env and change path (#158)

Co-authored-by: Mateusz Ziarko <[email protected]>
Co-authored-by: Maksymilian Pamuła <[email protected]>

* chore: version bump & docs update

Co-authored-by: Rafael Faria <[email protected]>
Co-authored-by: Tomasz Puch <[email protected]>
Co-authored-by: kamilszewczyk0 <[email protected]>
Co-authored-by: AndrzejBugdol <[email protected]>
Co-authored-by: Kamil Szewczyk <[email protected]>
Co-authored-by: Andrzej Bugdol <[email protected]>
Co-authored-by: Maksymilian Pamuła <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request solved Issue has been solved v4 Strapi v4
Projects
None yet
Development

No branches or pull requests

4 participants