Skip to content

Fix fetching comments through the API for accountability and budgets#15170

Closed
ahukkanen wants to merge 7 commits intodecidim:developfrom
mainio:fix/comments-api-accountability-budgets
Closed

Fix fetching comments through the API for accountability and budgets#15170
ahukkanen wants to merge 7 commits intodecidim:developfrom
mainio:fix/comments-api-accountability-budgets

Conversation

@ahukkanen
Copy link
Copy Markdown
Contributor

🎩 What? Why?

Currently fetching comments through the API for accountability results or budgeting projects is broken.

This is caused by the API authorization checks introduced at #13759.

Affected versions 0.28.5 and up.

📌 Related Issues

Testing

  1. Ensure that both the accountabiltiy result and budgeting project with IDs 1 have comments in them.
  2. Run the following query to the API to see either an exception or no results (repeat for both resource types Decidim::Accountability::Result and Decidim::Budgets::Project)
{
  commentable(type: "Decidim::Accountability::Result", id: "1", locale: "en", toggleTranslations: false) {
    totalCommentsCount
    comments {
      ...dataFragment
      comments {
        ...dataFragment
        comments {
          ...dataFragment
        }
      }
    }
  }
}

fragment dataFragment on Comment {
  id
  body
  author { name }
  createdAt
}

github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
The projects should be visible in the API result, I believe.
github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
As the comment authors are now confirmed user accounts, they add
to the total amount of users.
github-actions[bot]
github-actions bot previously approved these changes Sep 10, 2025
ahukkanen added a commit to City-of-Turku/decidim-module-apiext that referenced this pull request Sep 10, 2025
Apply the fix from the following core PR:
decidim/decidim#15170

Comments fetching was broken since 0.28.5 due to this breaking
change:
decidim/decidim#13759
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

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

@ahukkanen Could you merge with the latest develop branch ? Also could you check the suggestions?

Comment on lines +21 to +25
if result && !result.deleted?
allow!
else
disallow!
end
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.

why not a simple:

Suggested change
if result && !result.deleted?
allow!
else
disallow!
end
toggle_allow(result && !result.deleted?)

Comment on lines +51 to +55
if project && !project.deleted? && !project.budget.deleted?
allow!
else
disallow!
end
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.

Suggested change
if project && !project.deleted? && !project.budget.deleted?
allow!
else
disallow!
end
toggle_allow(project && !project.deleted? && !project.budget.deleted?)

@alecslupu
Copy link
Copy Markdown
Contributor

@ahukkanen thank you for your fix! I am closing this in favour of #15979, so that we can fix the outstanding issues.

@alecslupu alecslupu closed this Feb 2, 2026
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.

2 participants