Skip to content

Removing a personal endorsement/like removes it also from the group #10160

@ahukkanen

Description

@ahukkanen

Describe the bug
When the user belongs to a group and endorses an endorsable item both as herself and as the group, and after this removes the endorsement from herself, it also removes it from the group.

This happens both on 0.27 as well as in the redesign (0.28).

To Reproduce
Steps to reproduce the behavior:

  1. Go to try.decidim.org
  2. Login as a user that belongs to a group (e.g. the example admin)
  3. Find a blog article anywhere on the site (e.g. inside a process)
  4. When on the blog article page, click the "Endorse" button
  5. Select endorsement for both: the user and the group
  6. Remove the endorsement from the user (and the user only, leave group endorsement active)
  7. Reload the page
  8. Click the "Endorse" button again
  9. See that the group endorsement has also disappeared

The behavior is slightly different between the current layout and the redesigned layout, as they reload the endorsements in the modal slightly differently. However, the actual backend behavior is exactly the same in both.

Expected behavior
When unendorsing an item as a user, I would expect the group endorsement to remain intact.

Screenshots
This is a screencap of the situation at try.decidim.org:

decidim-group-endorsement-disappear.mp4

Stacktrace
N/A

Extra data (please complete the following information):

  • Device: Laptop
  • Device OS: Ubuntu 22.04
  • Browser: Chrome
  • Decidim Version: 0.27, 0.28 (develop), probably previous versions too
  • Decidim installation: try.decidim.org (or any other)

Additional context
It was noted in a related discussion at #9852 that this behavior is coming from this line in the code:

@resource.endorsements.where(author: @current_user)

The group endorsements look as follows in the database:

#<Decidim::Endorsement:0x00007f06646252c0                                       
 id: 210,
 resource_type: "Decidim::Blogs::Post",
 resource_id: 6,
 decidim_author_type: "Decidim::UserBaseEntity",
 decidim_author_id: 1,
 decidim_user_group_id: 6,
 ...>

Notice that even the group endorsement is bound to the user who initially did the endorsement. This means that the code line pointed out above also removes the group endorsement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions