Skip to content

CP-12376 extend webhooks partnerships#55

Merged
ryanarakawa merged 11 commits intomainfrom
CP-12376-extend-webhooks-partnerships
Feb 18, 2026
Merged

CP-12376 extend webhooks partnerships#55
ryanarakawa merged 11 commits intomainfrom
CP-12376-extend-webhooks-partnerships

Conversation

@ryanarakawa
Copy link
Collaborator

@ryanarakawa ryanarakawa commented Feb 16, 2026

Summary

This PR extends the webhook system to support partnerships in addition to accounts, enabling partnership-level webhook notifications for template webhook events.

Changes:

  • Add partnership_id to webhook_urls table with database constraint (webhooks belong to either account OR partnership)
  • Extract duplicate webhook retry logic from 11 job classes into shared WebhookRetryLogic module
  • Centralize webhook URL lookup into WebhookUrls module with routing for templates (account/partnership)
  • Automatic webhook creation for new partnerships with after_commit callback
  • Limit partnership webhooks to template events only (no submission/submitter events, which are only account level)

Manual Testing

  • Verify migration runs cleanly on fresh database
  • Test if any existing account webhooks still work
  • Create new partnership and verify webhook auto-created
  • Test partnership template creation triggers webhook
  • Test partnership template update triggers webhook

- add migration to make account_id OR partnership_id required, you can use either, but can and must use at least one
- add PARTNERSHIP_EVENTS constant to constrain webhook firing to just template events
- 11 webhook jobs all used the same retry logic (except one file that had 12 max retries instead of 10.
- remove and replace duplicated code
- add retry logic for partnership templates
- add for_template method to support account/partnership templates.
- for_account_id will still work for submissions
- update controllers with new method
- I'm not great with Arel, so I refactored since I wanted account/partnership to use a shared method.
@ryanarakawa ryanarakawa marked this pull request as ready for review February 17, 2026 20:48
The immediately following PR will add this `after_commit` back. We only really need the upcoming template.preferences_updated webhook event that will be in the next PR, so even though it's unlikely anyone will be testing this at the Partnership level right now, better to just remove it for the time being for a cleaner PR.
author: author)
end

def create_careerplug_webhook
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will get added back in the next PR. The only event we'll be using, template.preferences_updated will be in the next PR.

Copy link
Collaborator

@bernardodsanderson bernardodsanderson left a comment

Choose a reason for hiding this comment

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

This looks good!


def event_matcher(events)
events = Array.wrap(events)
conditions = events.map { 'events LIKE ?' }.join(' OR ')
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] Not a huge risk, but there is a possibility of SQL injection here. One possible thing to do is to validate them against a constant.

* safety against SQL injection

This method does not accept user input, but adding this just to be safe.
* since we added the events constant checker, we need to make sure this event is part of the constant list
@ryanarakawa ryanarakawa merged commit 41e18f9 into main Feb 18, 2026
5 checks passed
@ryanarakawa ryanarakawa deleted the CP-12376-extend-webhooks-partnerships branch February 18, 2026 20:37
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.

2 participants