NotificationEvent#
NAME#
Kernel::System::NotificationEvent - to manage the notifications
DESCRIPTION#
All functions to manage the notification and the notification jobs.
PUBLIC INTERFACE#
new()#
Don’t use the constructor directly, use the ObjectManager instead:
my $NotificationEventObject = $Kernel::OM->Get('Kernel::System::NotificationEvent');
NotificationList()#
returns a hash of all notifications
my %List = $NotificationEventObject->NotificationList(
Type => 'Ticket', # type of notifications; default: 'Ticket'
Details => 1, # include notification detailed data. possible (0|1) # ; default: 0
All => 1, # optional: if given all notification types will be returned, even if type is given (possible: 0|1)
);
NotificationGet()#
returns a hash of the notification data
my %Notification = $NotificationEventObject->NotificationGet(
Name => 'NotificationName',
);
my %Notification = $NotificationEventObject->NotificationGet(
ID => 1,
);
Returns:
%Notification = (
ID => 123,
Name => 'Agent::Move',
Data => {
Events => [ 'TicketQueueUpdate' ],
# ...
Queue => [ 'SomeQueue' ],
},
Message => {
en => {
Subject => 'Hello',
Body => 'Hello World',
ContentType => 'text/plain',
},
de => {
Subject => 'Hallo',
Body => 'Hallo Welt',
ContentType => 'text/plain',
},
},
Comment => 'An optional comment',
ValidID => 1,
CreateTime => '2010-10-27 20:15:00',
CreateBy => 2,
ChangeTime => '2010-10-27 20:15:00',
ChangeBy => 1,
UserID => 3,
);
NotificationAdd()#
adds a new notification to the database
my $ID = $NotificationEventObject->NotificationAdd(
Name => 'Agent::OwnerUpdate',
Data => {
Events => [ 'TicketQueueUpdate' ],
# ...
Queue => [ 'SomeQueue' ],
},
Message => {
en => {
Subject => 'Hello',
Body => 'Hello World',
ContentType => 'text/plain',
},
de => {
Subject => 'Hallo',
Body => 'Hallo Welt',
ContentType => 'text/plain',
},
},
Comment => 'An optional comment', # (optional)
ValidID => 1,
UserID => 123,
);
NotificationUpdate()#
update a notification in database
my $Ok = $NotificationEventObject->NotificationUpdate(
ID => 123,
Name => 'Agent::OwnerUpdate',
Data => {
Events => [ 'TicketQueueUpdate' ],
# ...
Queue => [ 'SomeQueue' ],
},
Message => {
en => {
Subject => 'Hello',
Body => 'Hello World',
ContentType => 'text/plain',
},
de => {
Subject => 'Hallo',
Body => 'Hallo Welt',
ContentType => 'text/plain',
},
},
Comment => 'An optional comment', # (optional)
ValidID => 1,
UserID => 123,
);
NotificationDelete()#
deletes an notification from the database
$NotificationEventObject->NotificationDelete(
ID => 1,
UserID => 123,
);
NotificationEventCheck()#
returns array of notification affected by event
my @IDs = $NotificationEventObject->NotificationEventCheck(
Event => 'ArticleCreate',
);
NotificationExport()#
export a notification
my $ExportData = $NotificationEventObject->NotificationExport(
# required either ID or ExportAll
ID => $NotificationID,
ExportAll => 0, # possible: 0, 1
UserID => 1, # required
Type => 'Ticket', # optional, default: 'Ticket'
All => 1 # optional, default: undef
}
returns Notification hashes in an array with data:
my $ExportData =
[
{
'ChangeTime' => '2024-02-06 14:49:56',
'ValidID' => 1,
'ID' => 16,
'CreateBy' => 1,
'Data' => {
'Transports' => [
'Email'
],
'LanguageID' => [
'en'
],
'VisibleForAgent' => [
'1'
],
'Events' => [
'UserMention'
],
'ArticleAttachmentInclude' => [
'0'
],
'AgentEnabledByDefault' => [
'Email'
],
'TransportEmailTemplate' => [
'Default'
]
},
'Name' => 'Mention notification',
'ChangeBy' => 1,
'Comment' => '',
'CreateTime' => '2024-02-06 14:49:56',
'Message' => {
'en' => {
'ContentType' => 'text/plain',
'Body' => 'Hi <OTRS_NOTIFICATION_RECIPIENT_UserFirstname>,
you have been mentioned in ticket <OTRS_TICKET_NUMBER>. <OTRS_AGENT_BODY[5]>
<OTRS_CONFIG_HttpType>://<OTRS_CONFIG_FQDN>/<OTRS_CONFIG_ScriptAlias>index.pl?Action=AgentTicketZoom;TicketID=<OTRS_TICKET_TicketID>
- – <OTRS_CONFIG_NotificationSenderName>’,
‘Subject’ => ‘Mention in ticket: <OTRS_TICKET_Title>’
}, ‘de’ => {
‘ContentType’ => ‘text/plain’, ‘Body’ => “Hallo <OTRS_NOTIFICATION_RECIPIENT_UserFirstname> <OTRS_NOTIFICATION_RECIPIENT_UserLastname>,
Sie wurden erwx{e4}hnt in Ticket <OTRS_TICKET_NUMBER>. <OTRS_AGENT_BODY[5]>
<OTRS_CONFIG_HttpType>://<OTRS_CONFIG_FQDN>/<OTRS_CONFIG_ScriptAlias>index.pl?Action=AgentTicketZoom;TicketID=<OTRS_TICKET_TicketID>
- – <OTRS_CONFIG_NotificationSenderName>”,
‘Subject’ => “Erwx{e4}hnung in Ticket: <OTRS_TICKET_Title>”
}
}
}
]
NotificationImport()#
import an Notification YAML file/content
my $NotificationImport = $NotificationEventObject->NotificationImport(
Content => $YAMLContent, # mandatory, YAML format
OverwriteExistingNotifications => 0, # optional, possible: 0, 1
UserID => 1, # mandatory
);
Returns:
$NotificationImport = {
Success => 1, # 1 if success or undef if operation could not
# be performed
Message => 'The Message to show.', # error message
Added => 'Notification1, Notification2', # string list of Notifications correctly added
Updated => 'Notification3, Notification4', # string list of Notifications correctly updated
NotUpdated => 'Notification5, Notification6', # string of Notifications not updated due to existing entity
# with the same name
Errors => 'Notification5', # string list of Notifications that could not be added or updated
AdditionalErrors => ['Some error occured!', 'Error2!'], # list of additional error not necessarily related to specified Notification
# for compatibility with existing code
AddedNotifications => 'Notification1, Notification2', # string list of Notifications correctly added
UpdatedNotifications => 'Notification3, Notification4', # string list of Notifications correctly updated
NotificationErrors => 'Notification5', # string list of Notifications that could not be added or updated
};
NotificationCopy()#
copy a notification
my $NewNotificationID = $NotificationEventObject->NotificationCopy(
ID => 1, # mandatory
UserID => 1, # mandatory
);
NotificationBodyCheck()#
Check if body has a proper length depending on DB type.
my $Ok = $NotificationEventObject->NotificationBodyCheck(
Content => $BodyContent, # mandatory
UserID => 1, # mandatory
);
NotificationExportDataGet()#
get data to export notification
my %NotificationData = $NotificationEventObject->NotificationExportDataGet(
ID => 1, # mandatory
);
Returns:
my %NotificationData = (
'ChangeTime' => '2024-02-06 14:49:56',
'ValidID' => 1,
'ID' => 16,
'CreateBy' => 1,
'Data' => {
'Transports' => [
'Email'
],
'LanguageID' => [
'en'
],
'VisibleForAgent' => [
'1'
],
'Events' => [
'UserMention'
],
'ArticleAttachmentInclude' => [
'0'
],
'AgentEnabledByDefault' => [
'Email'
],
'TransportEmailTemplate' => [
'Default'
]
},
'Name' => 'Mention notification',
'ChangeBy' => 1,
'Comment' => '',
'CreateTime' => '2024-02-06 14:49:56',
'Message' => {
'en' => {
'ContentType' => 'text/plain',
'Body' => 'Hi <OTRS_NOTIFICATION_RECIPIENT_UserFirstname>,
you have been mentioned in ticket <OTRS_TICKET_NUMBER>. <OTRS_AGENT_BODY[5]>
<OTRS_CONFIG_HttpType>://<OTRS_CONFIG_FQDN>/<OTRS_CONFIG_ScriptAlias>index.pl?Action=AgentTicketZoom;TicketID=<OTRS_TICKET_TicketID>
- – <OTRS_CONFIG_NotificationSenderName>’,
‘Subject’ => ‘Mention in ticket: <OTRS_TICKET_Title>’
}, ‘de’ => {
‘ContentType’ => ‘text/plain’, ‘Body’ => “Hallo <OTRS_NOTIFICATION_RECIPIENT_UserFirstname> <OTRS_NOTIFICATION_RECIPIENT_UserLastname>,
Sie wurden erwx{e4}hnt in Ticket <OTRS_TICKET_NUMBER>. <OTRS_AGENT_BODY[5]>
<OTRS_CONFIG_HttpType>://<OTRS_CONFIG_FQDN>/<OTRS_CONFIG_ScriptAlias>index.pl?Action=AgentTicketZoom;TicketID=<OTRS_TICKET_TicketID>
- – <OTRS_CONFIG_NotificationSenderName>”,
‘Subject’ => “Erwx{e4}hnung in Ticket: <OTRS_TICKET_Title>”
}
}
)
NotificationExportFilenameGet()#
get export file name based on notification name & type
my $Filename = $NotificationEventObject->NotificationExportFilenameGet(
Type => 'Appointment',
Name => 'notification_1',
Format => 'YAML',
);