RT::Ex...OnShift(3pm)
π RT::Extension::SMSNotify::IsOnShift π
okay bestie, so this is one of those User Contributed Perl Documentation pages, and it's giving "small module, very specific job, absolutely slays at it." it's RT::Extension::SMSNotify::IsOnShift, and yes, that truncated little RT::Ex...OnShift you see in the header is just the man page being shy about long names. she's long, she's valid, she's iconic. π
β¨ NAME β¨
RT::Extension::SMSNotify::IsOnShift β enable notifications based on shifts πΈ
π DESCRIPTION π
so this is an example module, and what it does is chef's kiss honestly: it uses a 'ShiftCode' custom field on users to look shift definitions up from the RT config file, and it returns user phone numbers only if they are currently on shift. that's the whole vibe. no shift, no number, no text. π¦
π CONFIGURATION π
first things first: this module has to be specified as a phone number lookup function, and you do that by passing the module name. RT::Extension::SMSNotify will go looking for a function named GetPhoneForUser in the module, exactly as described in the docs for $SMSNotifyGetPhoneForUserFn. so:
Set($SMSNotifyGetPhoneForUserFn, 'RT::Extension::SMSNotify::IsOnShift');
now, the RT config $SMSNotifyShiftMap needs to be set to a hashref pointing to a hash. in that hash, the shift names are the 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 of those values are integers representing minutes since midnight UTC, and they live in the range 0 <= x < 1440. like so:
Set($SMSNotifyShiftMap, {
'AU' => [22*60+0, 4*60+0],
'UK' => [8*60+30, 17*60+30]
});
β οΈ bestie, be careful about leading zeroes, because Perl will interpret the value as octal. and that's not a vibe, that's a bug. look:
$ 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. so please, for the love of everything, make sure you define your shifts and user assignments carefully. π
π«Ά AUTHOR π«Ά
Craig Ringer <craig@2ndquadrant.com>
π COPYRIGHT π
Copyright 2013 2ndQuadrant
Released under the same license as Perl its self.
π§ GetPhoneForUser π§
this one looks up the PagerPhone field of the specified user and returns it only if the user is currently on shift β which it figures out according to their 'ShiftCode' custom field, as looked up in the RT configuration 'SMSNotifyShiftMap'.
see the configuration section, and also RT::Extension::SMSNotify. π
and that's the whole page, bestie β no notes, she ate. β¨ this was perl v5.32.0, dated 2021-01-09, and yes we're signing off with the full RT::Ex...OnShift(3pm) moment because the header deserves her flowers. stay on shift, stay hydrated, mwah. πππ¦
π¦ where this page comes from
- debian bookworm: rt4-extension-smsnotify 1.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: rt4-extension-smsnotify 1.04-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms