RT::Ex...OnShift(3pm)

πŸ“¦
version 1.04 Β· 2 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

RT::Extension::SMSNotify::IsOnShift β€” the little module that makes notifications shift-aware πŸ’– no cap, it literally only hands over phone numbers when the human is clocked in.


✨ DESCRIPTION ✨

Okay so bestie, picture this: it's a whole example module that uses a 'ShiftCode' custom field on users πŸŽ€ to go look up shift definitions from the RT config file, and then it returns user phone numbers only if those users are currently on shift. That's it, that's the vibe. πŸ‘‘


πŸŽ€ CONFIGURATION πŸŽ€

So first things first: this module has to be specified as a phone number lookup function, by passing the module name. RT::Extension::SMSNotify will go hunting for a function named "GetPhoneForUser" inside the module, exactly as the docs for $SMSNotifyGetPhoneForUserFn say. 🫢

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 they live 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, because Perl will interpret the value as octal and absolutely humble you:
$ perl -e 'print 0600 . "\n"';
384

And 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. So make sure you define your shifts and user assignments carefully. πŸ’€ fr fr, no shortcuts here.


πŸ’– AUTHOR πŸ’–

Craig Ringer <craig@2ndquadrant.com>


Copyright 2013 2ndQuadrant

Released under the same license as Perl its self.


GetPhoneForUser

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.


And that's a wrap, bestie β€” this icon of a page came to you from RT::Ex...OnShift(3pm), shipped as perl v5.40.1, dated 2025-03-22. πŸ’…βœ¨

πŸ“¦ where this page comes from