Skip to content

1959 - send webhook to RMD when open access work is published#1973

Open
Karthik Koralla (karthikreddy-02) wants to merge 1 commit into
mainfrom
1959-open-access-work-published-webhook
Open

1959 - send webhook to RMD when open access work is published#1973
Karthik Koralla (karthikreddy-02) wants to merge 1 commit into
mainfrom
1959-open-access-work-published-webhook

Conversation

@karthikreddy-02
Copy link
Copy Markdown
Contributor

When an Open Access work is published in ScholarSphere, send a webhook to RMD so it can create an OpenAccessLocation for the matching deposit.

Changes:

Add WorkPublishedWebhook service that POSTs /webhooks/scholarsphere/open_access_work_published to RMD with the work's URL path
Add WorkPublishedWebhookJob to enqueue the webhook asynchronously
Trigger the job via after_commit on the publish AASM event in WorkVersion, only when the work is open access
Depends on: psu-libraries/researcher-metadata#1232

Closes #1959

Comment on lines +236 to +240
after_commit do
if work.open_access?
WorkPublishedWebhookJob.perform_later(work.uuid)
end
end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this valid syntax? Did you test it? There are no specs for this.

@@ -0,0 +1,20 @@
# frozen_string_literal: true

class WorkPublishedWebhook
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should modularize our webhooks services and move them into the services/webhooks directory.

@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'shoulda/matchers'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why was this added?

self.reload_on_index = true
}
end
# rubocop:enable Metrics/BlockLength
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than disabling, can this be refactored? If it can't it might be better to just disable this cop for this file in the rubocop.yml.

end
# rubocop:enable Metrics/BlockLength

# Fields that can contain multiple values...
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open Access Scholarly Work publish webhook

2 participants