Skip to content

Notifications

Henne Vogelsang edited this page Oct 7, 2021 · 28 revisions

Details about our notification sub-system. It is based on the Event, EventSubscription and Notification classes.

Workflow

  • An Event gets stored in the database
  • clockwork periodically schedules a SendEventEmailsJob every 30 seconds.
  • SendEventEmailsJob goes over the Event table and
    • EventMailer sends email all Event that have email subscribers
    • NotificationService::Notifier creates Notification for all Event that have web/rss subscribers
    • Once done Event.mails_sent is set to true

Event

An Event describes things that happen throughout the whole OBS. See the Events docu for details.

EventSubscription

We subscribe to an event by creating an instance of EventSubscription in the database.

A Subscription is specific for a User, a Group, a type of Event (eventtype=Event::CommentForPackage), a Role the User might have (receiver_role="maintainer") and the place where it should be displayed (channel=web, channel=instant_email)

The code below will, for instance, create an email subscription for the user henne for all Event::BuildFail events, concerning packages henne is maintainer of.

EventSubscription.create(eventtype: "Event::BuildFail",
                         receiver_role: "maintainer",
                         user: User.find_by(login: 'henne'),
                         channel: "instant_email",
                         enabled: true)

App Wide Default Subscriptions

All EventSubscription instances that have neither the user nor the group attribute set are considered for all users and groups. Those defaults can only be created by OBS admins via the UI. In a fresh OBS installation there are no instances of EventSubscription.

Notifications

A Notification is for a specific Event, a specific User (subscriber_id=1) and one or more places where it should be displayed (rss=true, web=false).

Clone this wiki locally