RT::Extension::SMSNotify::OnShift(3pm) | User Contributed Perl Documentation | RT::Extension::SMSNotify::OnShift(3pm) |
RT::Extension::SMSNotify::IsOnShift - enable notifications based on shifts
An example that uses a 'ShiftCode' custom field on users to look shift definitions up from the RT config file and return user phone numbers only if they are currently on shift.
This module must be specified as a phone number lookup function by passing the module name. RT::Extension::SMSNotify will look for a function named "GetPhoneForUser" in the module as per the docs for $SMSNotifyGetPhoneForUserFn.
Set($SMSNotifyGetPhoneForUserFn, 'RT::Extension::SMSNotify::IsOnShift');
Now the RT config $SMSNotifyShiftMap must be set to a hashref pointing to a hash where the shift names are keys and the values are arrayrefs pointing to two-element arrays of integers. Each key is a shift code that matches the ShiftCode custom field values. Both values are integers representing minutes since midnight UTC and are in the range 0 <= x < 1440. For example:
Set($SMSNotifyShiftMap, { 'AU' => [22*60+0, 4*60+0], 'UK' => [8*60+30, 17*60+30] });
Be careful to avoid leading zeroes, since Perl will interpret the value as octal:
$ perl -e 'print 0600 . "\n"'; 384
At this point there's no provision for special notification rules if no users are found on shift, since the filter function only sees one user at a time. Make sure you define your shifts and user assignments carefully.
Craig Ringer <craig@2ndquadrant.com>
Copyright 2013 2ndQuadrant
Released under the same license as Perl its self.
Look up the PagerPhone field of the specified user and return it only if the user is currently on shift according to their 'ShiftCode' custom field as looked up in the RT configuration 'SMSNotifyShiftMap'.
See the configuration section and RT::Extension::SMSNotify.
2021-01-09 | perl v5.32.0 |