Skip to content

[WIP] fix user can comment in private assembly even if user don't have permissions#4893

Closed
isaacmg410 wants to merge 3 commits intomasterfrom
fix_user_cant_comment_to_private_assembly
Closed

[WIP] fix user can comment in private assembly even if user don't have permissions#4893
isaacmg410 wants to merge 3 commits intomasterfrom
fix_user_cant_comment_to_private_assembly

Conversation

@isaacmg410
Copy link
Copy Markdown
Contributor

🎩 What? Why?

This PR fixes that as a normal user (no private user) I can comment on a private assembly where is available. Meetigns, Proposals, etc.

📌 Related Issues

📋 Subtasks

  • Add CHANGELOG entry
  • Add documentation regarding the feature
  • Add/modify seeds
  • Add tests
  • Another subtask

📷 Screenshots (optional)

Description

@ghost ghost assigned isaacmg410 Feb 22, 2019
@ghost ghost added the status: WIP label Feb 22, 2019
@isaacmg410 isaacmg410 changed the title fix user can comment in private assembly even if user don't have permissions [WIP] fix user can comment in private assembly even if user don't have permissions Feb 22, 2019
@isaacmg410
Copy link
Copy Markdown
Contributor Author

I have created a new method in decidim-comments/lib/decidim/comments/commentable.rb with true by default. And then each class that includes Commentable can override this method.
Also, I have created a new field in commentable_interface.rb which expects a context for a user, to check if has permissions to create comments or not.

For now, the problem is that there is no way to receive the user by context in order to check if he has permission to participate in that specific ParticipatorySpace (in that case, Assembly Private and Transparent).

Right now, I am only working with Meetings, but it will have to be extended to Proposals, Posts, etc.,

@decidim/lot-core Can someone help me, to understand what I'm doing wrong please? Or give me some directions to be follow with GraphQl and React, please?

@mrcasals
Copy link
Copy Markdown
Contributor

@isaacmg410 I don't understand what problem are you facing. Can't you use obj from the interface to find the commentable resource and its participatory space, and ctx to get the user?

@isaacmg410
Copy link
Copy Markdown
Contributor Author

@mrcasals I have not found the way in how to get, obj and ctx. So I ask for help to know what I'm doing wrong. Can we speak offline next Monday and review it?

end

field :userCanComment, !types.Boolean, "Check if the current user can comment" do
resolve lambda { |obj, _args, ctx|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isaacmg410 here are obj and ctx, use those!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrcasals I have created this field. The problem is that I overwrite the method user_can_comment?(user) for example meetings, and I try to pass the user without success... And comments doesn't load...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just do something like?

obj.commentable? && obj.can_participate?(ctx[:current_user])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I have already solved, in another branch. I will create a new PR today and close this one.

The question now is that I do not have any idea on how to solve and render the comment to the public side. Any idea?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question now is that I do not have any idea on how to solve and render the comment to the public side. Any idea?

I don't understand this, aren't the comments already rendered?

@isaacmg410 isaacmg410 force-pushed the fix_user_cant_comment_to_private_assembly branch from 4f51a4a to 379a784 Compare March 1, 2019 07:55
@isaacmg410
Copy link
Copy Markdown
Contributor Author

Close in favour of #4924

@isaacmg410 isaacmg410 closed this Mar 4, 2019
@isaacmg410 isaacmg410 deleted the fix_user_cant_comment_to_private_assembly branch March 25, 2019 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I can comment as a normal user in a private assembly

3 participants