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

πŸ“¦ version 1.04, in debian bookworm, ubuntu jammy

πŸ’– 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 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