Notifications

Introduction

The notification entity holds information about which user should have received a notification and what contents this notification has. Also, the seen and read information for a notification is stored in this table.

Notifications are related to many different entities as polymorphic relations which intratool will resolve by given keys.

An internal notification basically consists of:

  • Type

  • Target entity

  • Notifiable entity

to resolve which type of information should be dispatched to whom.

Model Definition

Relations

Relation
Key
Type
Relation Field(s)

Targetable (see below)

notifiable

Morph to

notifiable_type, notifiable_id

Notifiable (see below)

targetable

Morph to

targetable_type, targetable_id

Targetable types

Notifiable types

Types

  • infoboardPostCreated

  • infoboardPostUpdated

  • infoboardCommentCreated

  • calendarEventCreated

  • calendarEventUpdated

  • ManualEntryCreated

  • ManualEntryUpdated

  • generic

List

Get a list of all Notifications thar are related to the current authenticated User.

Definition

GET /api/notifications

Example Request

Example Response

Count

Get the count of all Notifications the current authenticated User is allowed to view.

Definition

GET /api/notifications/count

Example Request

Example Response

List by target entity type

Lists all Notifications with the given target entity type. This enables you to get all notifications related to a specific type of content.

Definition

GET /api/notifications/type/{targetEntityType}

Example Request

Example Response

List by target entity

Lists all Notifications with the given target entity type and target entity ID. This enables you to get all notifications related to a specific content.

Definition

GET /api/notifications/{targetEntityType}/{targetEntity}

Example Request

Example Response

Show

Show a single Notification by id.

Definition

GET /api/notifications/{id}

Example Request

Example Response

Create

Create a new Notification.

This will dispatch a generic notification based on given information to all clients within the given departments and / or users and should be used with care.

Definition

POST /api/notifications

Request Keys

Key
Type
Default
Description

title *

string

-

The title of the notification.

body*

string

-

The body text of the notification.

url *

string

-

The url the dispatched notification should point to.

department_ids

array

The array of departments that should be targeted by the notification.

user_ids

array

-

The array of users that should be targeted by the notification.

The fields with * are required.

Advanced Key-Specifications

  • department_ids - The array needs to contain valid department ids as integers.

  • user_ids - The array needs to contain valid user ids as integers.

  • user_ids - Needs to be filled if there are no department_ids

Example Request

Example Response

Update for user

Update all unread notifications for the current authenticated user. This route will return the count of affected rows on success.

Definition

PUT /api/notifications/

Request Keys

Key
Type
Default
Description

seen_at *

datetime

NULL

The timestamp when a user has seen the notification.

read_at*

datetime

NULL

The timestamp when a user has read the notification.

The fields with * are required.

Advanced Key-Specifications

  • read_at - This value will also set the seen_at information if no value is given for seen_at

Example Request

Example Response

Update

Update a Notification.

Definition

PUT /api/notifications/{id}

Request Keys

Key
Type
Default
Description

seen_at *

datetime

NULL

The timestamp when a user has seen the notification.

read_at*

datetime

NULL

The timestamp when a user has read the notification.

The fields with * are required.

Advanced Key-Specifications

  • read_at - This value will also set the seen_at information if no value is given for seen_at

Example Request

Example Response

Update by target entity type

Update all notifications of the current authenticated user for a specific type.

This enables you to mass update all notifications of a specific target type.

This route will return the count of affected rows on success.

Definition

PUT /api/notifications/{targetableType}

Request Keys

Key
Type
Default
Description

seen_at *

datetime

NULL

The timestamp when a user has seen the notification.

read_at*

datetime

NULL

The timestamp when a user has read the notification.

The fields with * are required.

Advanced Key-Specifications

  • read_at - This value will also set the seen_at information if no value is given for seen_at

Example Request

Example Response

Update by target entity

Update a unread notification of the current authenticated user by it's target. This is useful if you want to update a notification related to a specific content.

Definition

PUT /api/notifications/{targetableType}/{targetableId}

Request Keys

Key
Type
Default
Description

seen_at *

datetime

NULL

The timestamp when a user has seen the notification.

read_at*

datetime

NULL

The timestamp when a user has read the notification.

The fields with * are required.

Advanced Key-Specifications

  • read_at - This value will also set the seen_at information if no value is given for seen_at

Example Request

Example Response

Last updated