<div dir="auto">Once all of these pieces are worked out, we can also discuss packaging the settings, a couple of example action triggers, and other changes up into a branch to submit to core Evergreen so that future libraries that decide to implement it will have fewer steps. </div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Jan 17, 2025, 6:29 PM Ken Cox via Eg-newdevs <<a href="mailto:eg-newdevs@list.evergreen-ils.org">eg-newdevs@list.evergreen-ils.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dan,<div><br></div><div>I did stay interested for the whole video, and I found it quite informative. Thank you! I am persuaded by your investigation and arguments that:</div><div><br></div><div>a) using hemlock.push_notification_data as the Opt-In Setting Type is not working as intended because it is a string, and</div><div>b) the simplest and thus the best solution is for the Hemlock app to store two user settings:</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>hemlock.push_notification_data - the push notification token itself</div></blockquote></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>hemlock.push_notification_enabled - boolean true when we have a push notification token</div></div><div><br></div></blockquote><div>I think in the near future we may want a timestamp as well. Sadly this means a third user setting type, because the actor.usr_setting table does not include a timestamp:</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>hemlock.push_notification_ts - timestamp when hemlock.push_notification_data was last modified</div></blockquote></div><div><br></div><div>According to <a href="https://firebase.google.com/docs/cloud-messaging/manage-tokens" target="_blank" rel="noreferrer">Best practices for FCM registration token management</a>, if an FCM token becomes stale, we should stop trying to use it. Currently, the Hemlock app only writes the token (via open-ils.actor.patron.settings.update) when it is different from what it fetched. We don't want to rewrite it on every launch. I don't have all the moving parts worked out yet, but I think we have to rely on Evergreen to detect "staleness", because we can't be guaranteed the app will ever run again on that device. But if Evergreen is detecting stale tokens and deleting them (or setting hemlock.push_notification_enabled to false), then the app needs to run periodically in order to refresh the token, and there could be windows where it is possible to miss notifications.</div><div><br></div><div>Gina -- if you agree (on adding an "enabled" setting for now), please go ahead and add it and I can update the app to set it to true. Or we can discuss further in chat or at the next "new devs" meeting.</div><div><br></div><div>Ken</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 17, 2025 at 2:05 PM Dan Briem via Eg-newdevs <<a href="mailto:eg-newdevs@list.evergreen-ils.org" target="_blank" rel="noreferrer">eg-newdevs@list.evergreen-ils.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I tested the action trigger with the opt-in feature and a custom filter (recording here: <a href="https://youtu.be/n--asMO61g8" target="_blank" rel="noreferrer">https://youtu.be/n--asMO61g8</a>).<div><br></div><div>Granted, I haven't been at the meetings, so hopefully I didn't misunderstand what we were trying to do (or how the Hemlock setting works).<br><div><br></div><div>The opt-in setting feature didn't work for me because I used a string (I'm assuming it is) and Evergreen checks for a "true" boolean value. When I ran it as a custom filter, it worked.</div><div><br></div><div>As an alternative, maybe Hemlock can create another user setting that's a boolean in addition to the token so we can use the opt-in setting feature instead? This would be good for active hooks, like hold.available. Or, maybe on the Evergreen side, the opt-in setting feature could be expanded to include conditions or something like that (not sure if that's the way to go, though).</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 16, 2025 at 10:52 AM Gina Monti via Eg-newdevs <<a href="mailto:eg-newdevs@list.evergreen-ils.org" target="_blank" rel="noreferrer">eg-newdevs@list.evergreen-ils.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks so much, Michele! I'll give this a shot and will report back.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 16, 2025 at 10:13 AM Morgan, Michele <<a href="mailto:mmorgan@noblenet.org" target="_blank" rel="noreferrer">mmorgan@noblenet.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_default" style="font-family:verdana,sans-serif">After Gina shared their experiences with setting up a Hemlock push notifications action trigger at the meeting yesterday, I wondered again about using the opt-in functionality built into the action triggers to limit which patrons receive the notifications, rather than a custom filter. We have several action triggers running successfully in production using user settings to allow patrons to opt-in to certain notices, so I wasn't sure what would be different with this one.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">I took a little time to try setting one up on one of our test systems using the user setting type in the '<b>Opt-in Setting Type</b>' field in the event definition. Long story short, it worked for me! No custom filter was necessary, and events were only created for the patron with the user setting set.</div><div class="gmail_default"><br></div><div class="gmail_default">To set up the definition, I cloned one of our existing overdue notification triggers, saying <b>Yes to cloning the Environment.</b> Then I edited the definition to use the Hemlock push notifications user setting.</div><div class="gmail_default"><br></div><div class="gmail_default">These are the fields from the event definition that worked:</div><div class="gmail_default"><br></div><div class="gmail_default">Owning Library: NOBLE <i>(Consortium)</i></div><div class="gmail_default">Name: Hemlock push notifications</div><div class="gmail_default">Hook: checkout.due</div><div class="gmail_default">Enabled: true</div><div class="gmail_default">Processing Delay: 1 day</div><div class="gmail_default">Processing Delay Context Field: due_date</div><div class="gmail_default">Processing Group Context Field: usr</div><div class="gmail_default">Reactor: <b>ProcessTemplate</b> <i>(for testing, so the event_output will be generated, but nothing else will happen. For production, this would be <b>CallHTTP</b>)</i></div><div class="gmail_default">Validator: CircIsOpen</div><div class="gmail_default">Event Repeatability Delay: <b>00:01:00</b> <i>(for testing, allowing duplicate events to be created after 1 minute for subsequent runs of the trigger)</i></div><div class="gmail_default">Granularity: <b>hemlock_push</b> <i>(for testing: to control when the trigger runs, can be used for production as well)</i></div><div class="gmail_default">Max Event Validity Delay: 10 days</div><div class="gmail_default">Opt-In Setting Type: <b>hemlock.push_notification_data</b></div><div class="gmail_default">Opt-In User Field: <b>usr</b></div><div class="gmail_default">Retention Interval: 6 mons</div><div class="gmail_default"><b>Template:</b> <i>(from Ken's documentation: <a href="https://github.com/kenstir/hemlock-docs/blob/main/docs/pn-setup-guide/configure-evergreen.md#sample-template" target="_blank" rel="noreferrer">https://github.com/kenstir/hemlock-docs/blob/main/docs/pn-setup-guide/configure-evergreen.md#sample-template</a>)</i></div><div class="gmail_default">Context Bib Path: target_copy.call_number.record</div><div class="gmail_default">Context Item Path: target_copy</div><div class="gmail_default">Context Library Path: circ_lib</div><div class="gmail_default">Context User Path: usr</div><div class="gmail_default"><br></div><div class="gmail_default">This command will run only this trigger based on its granularity:</div><div class="gmail_default"><br></div><div class="gmail_default">/openils/bin/<a href="http://action_trigger_runner.pl" target="_blank" rel="noreferrer">action_trigger_runner.pl</a> --osrf-config /openils/conf/opensrf_core.xml --process-hooks --run-pending --granularity hemlock_push --granularity-only</div><div class="gmail_default"><br></div><div class="gmail_default">Running this trigger will look at circulations due between one day and ten days ago. On my test system, there are seven open circulations due in this time period. I set the user setting hemlock.push_notification_data for one user linked to two of those checkouts. Only two events were created, linked to one row that was created in event_output. </div><div class="gmail_default"><br></div><div class="gmail_default">I removed the user setting from the patron and ran the trigger again after one minute. No events were created. Here is the log entry showing the criteria for gathering the circs:</div><div class="gmail_default"><br></div><div class="gmail_default">[2025-01-16 14:35:46] open-ils.trigger [INFO:307910:CStoreEditor.pm:155:173703694530637333] editor[1|0] request en-US open-ils.cstore.direct.action.circulation.id_list.atomic [{"checkin_time":null,"-and":[{"+atev":{"id":null}},<b>{"-exists":{"from":"aus","where":{"name":"hemlock.push_notification_data","value":"true","usr":{"=":{"+circ":"usr"}}}}}</b>],"due_date":{"between":["2025-01-06 14:35:46+0000","2025-01-15 14:35:46+0000"]},"circ_lib":{"in":{"where":{"id":1},"select":{"aou":[{"transform":"actor.org_unit_descendants","column":"id","result_field":"id"}]},"from":"aou"}},"-or":[{"stop_fines":["MAXFINES"]},{"stop_fines":null}]},{"join":{"atev":{"type":"left","fkey":"id","filter":{"event_def":585,"start_time":{">":"2025-01-16 14:34:46+0000"}},"field":"target"}}}]</div><div class="gmail_default"><br></div><div class="gmail_default">So the opt-in setting should definitely work to limit events to patrons with the setting, there should be no need for a custom filter.</div><div class="gmail_default"><br></div><div class="gmail_default">I hope this is helpful! We're definitely interested in this feature also!</div><div class="gmail_default"><br></div></div><div class="gmail_default" style="font-family:verdana,sans-serif">Michele</div></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:verdana,sans-serif"><br></span></div><div><span style="font-family:verdana,sans-serif">--</span><br></div><div><font face="verdana, sans-serif">Michele M. Morgan, <span style="font-size:12.8px">Systems Support Specialist<br></span></font></div><div><span style="font-size:12.8px"><font face="verdana, sans-serif">North of Boston Library Exchange, Danvers Massachusetts</font></span></div><div><span style="font-size:12.8px"><a href="mailto:mmorgan@noblenet.org" target="_blank" rel="noreferrer"><font face="verdana, sans-serif">mmorgan@noblenet.org</font></a></span></div><div><br></div></div></div></div></div></div></div></div></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><img><br></div>Gina Monti (she/her)<div><div>Evergreen Systems Manager</div><div>Bibliomation, Inc.</div><div>(203) 577-4070 ext. 109</div></div><div>English, American Sign Language</div></div></div>
_______________________________________________<br>
Eg-newdevs mailing list<br>
<a href="mailto:Eg-newdevs@list.evergreen-ils.org" target="_blank" rel="noreferrer">Eg-newdevs@list.evergreen-ils.org</a><br>
<a href="http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs" rel="noreferrer noreferrer" target="_blank">http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs</a><br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Dan Briem<br>Harrison Public Library</div><div><a href="https://www.google.com/maps/search/2+Bruce+Ave.+Harrison,+NY+10528?entry=gmail&source=g">2 Bruce Ave. Harrison, NY 10528</a></div><div>(914) 835-0324<br><div><a href="https://www.harrisonpl.org" target="_blank" rel="noreferrer">harrisonpl.org</a></div></div></div></div></div></div>
_______________________________________________<br>
Eg-newdevs mailing list<br>
<a href="mailto:Eg-newdevs@list.evergreen-ils.org" target="_blank" rel="noreferrer">Eg-newdevs@list.evergreen-ils.org</a><br>
<a href="http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs" rel="noreferrer noreferrer" target="_blank">http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs</a><br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">-Ken</div>
_______________________________________________<br>
Eg-newdevs mailing list<br>
<a href="mailto:Eg-newdevs@list.evergreen-ils.org" target="_blank" rel="noreferrer">Eg-newdevs@list.evergreen-ils.org</a><br>
<a href="http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs" rel="noreferrer noreferrer" target="_blank">http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs</a><br>
</blockquote></div>