Skip to content

Notification landing fails when the notification is an attachment #15949

@davidbeig

Description

@davidbeig

Describe the bug

After the #15002 there seems to be a bug when the notification is an attachment.

Since now the cell checks if the user can participate in that resource, that asks the attachment model for a method that does not exist.

    def show
      if !notification.can_participate?(current_user)
        render :not_available
      elsif notification.deleted_resource?
        render :deleted
      elsif notification.hidden_resource?
        render :moderated
      else
        render :show
      end
    end

This has caused problems with other models, such as in this pr #15830

To Reproduce

  1. Upload an attachment to a process with one admin user
  2. Go to the notifications of a second admin user
  3. See it crash

Expected behavior

You can access the notification landing and see the notifications of type Decidim::Attachment

Screenshots

No response

Stacktrace

Cause: NoMethodError: undefined method can_participate?' for an instance of Decidim::Attachment /usr/local/bundle/gems/activemodel-7.2.3/lib/active_model/attribute_methods.rb:512:in method_missing'
/usr/local/bundle/gems/activerecord-7.2.3/lib/active_record/attribute_methods.rb:495:in method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/models/decidim/notification.rb:41:in can_participate?'
/usr/local/lib/ruby/3.3.0/delegate.rb:87:in method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/cells/decidim/notification_cell.rb:10:in show'

Extra data

  • Decidim Version: 0.31 (release branch)
  • Decidim installation: Participa Navarra

Additional context

No response

Metadata

Metadata

Assignees

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