+3
-4
events.go
+3
-4
events.go
···
5
5
type Event string
6
6
7
7
const (
8
-
// EventClearScheduledJobs is used to clear all future scheduled jobs for a given churros object
9
-
// For example, when adding a new ticket to an event, we want to unschedule all future notifications for the event since the shotgun date may have changed
10
-
EventClearScheduledJobs Event = "clear_scheduled_jobs"
11
8
EventClearStoredSchedule Event = "clear_stored_schedule"
12
9
EventShowScheduledJobs Event = "show_scheduled_jobs"
13
10
EventSaveSchedule Event = "save_schedule"
···
34
31
Id string `json:"id"`
35
32
// When to push the notification
36
33
SendAt time.Time `json:"send_at"`
34
+
// Clear scheduled jobs for the object_id before scheduling notifications
35
+
ClearSchedule bool `json:"clear_schedule"`
37
36
// Type of event that triggered the notification
38
37
// next-line-generate event-enum-jsonschema-values
39
-
Event Event `json:"event" jsonschema:"enum=clear_scheduled_jobs,enum=clear_stored_schedule,enum=show_scheduled_jobs,enum=save_schedule,enum=restore_schedule,enum=restore_schedule_eager,enum=clear_schedule,enum=new_post,enum=godchild_request,enum=custom,enum=test,enum=godchild_accepted,enum=godchild_rejected,enum=pending_signup,enum=login_stuck,enum=booking_paid,enum=contribution_paid,enum=shotgun_opens_soon,enum=shotgun_closes_soon"`
38
+
Event Event `json:"event" jsonschema:"enum=clear_stored_schedule,enum=show_scheduled_jobs,enum=save_schedule,enum=restore_schedule,enum=restore_schedule_eager,enum=clear_schedule,enum=new_post,enum=godchild_request,enum=custom,enum=test,enum=godchild_accepted,enum=godchild_rejected,enum=pending_signup,enum=login_stuck,enum=booking_paid,enum=contribution_paid,enum=shotgun_opens_soon,enum=shotgun_closes_soon"`
40
39
// Churros ID of the ressource (the ticket, the post, the comment, etc)
41
40
// Used to determine to whom the notification should be sent
42
41
// For godchild_request, this is not a user id, but a godparent request id.
+1
-2
receiver.go
+1
-2
receiver.go
···
23
23
ll.Log("Received", "cyan", "%-10s | %-10s on %s", message.Id, message.Event, message.ChurrosObjectId)
24
24
}
25
25
26
-
if message.Event == EventClearScheduledJobs {
26
+
if message.ClearSchedule {
27
27
UnscheduleAllForObject(message.ChurrosObjectId)
28
-
return nil
29
28
}
30
29
31
30
message.Schedule()
-1
typescript-dist/index.js
-1
typescript-dist/index.js
···
2
2
var Event = /* @__PURE__ */ ((Event2) => {
3
3
Event2["BookingPaid"] = "booking_paid";
4
4
Event2["ClearSchedule"] = "clear_schedule";
5
-
Event2["ClearScheduledJobs"] = "clear_scheduled_jobs";
6
5
Event2["ClearStoredSchedule"] = "clear_stored_schedule";
7
6
Event2["ContributionPaid"] = "contribution_paid";
8
7
Event2["Custom"] = "custom";
+2
-2
typescript-dist/index.js.map
+2
-2
typescript-dist/index.js.map
···
1
1
{
2
2
"version": 3,
3
3
"sources": ["../typescript/message.ts", "../typescript/constants.ts"],
4
-
"sourcesContent": ["export interface Message {\n /**\n * URL to go to when the action button is clicked\n */\n action: string;\n /**\n * Additional action buttons\n */\n actions?: Action[];\n /**\n * Notification body\n */\n body: string;\n /**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\n event: Event;\n /**\n * Unique ID for the notification scheduling request.\n */\n id: string;\n /**\n * URL to an image to display in the notification\n */\n image?: string;\n /**\n * Churros ID of the ressource (the ticket, the post, the comment, etc)\n * Used to determine to whom the notification should be sent\n * For godchild_request, this is not a user id, but a godparent request id.\n */\n object_id: string;\n /**\n * When to push the notification\n */\n send_at: Date;\n /**\n * Notification title\n */\n title: string;\n}\n\nexport interface Action {\n action: string;\n label: string;\n}\n\n/**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\nexport enum Event {\n BookingPaid = \"booking_paid\",\n ClearSchedule = \"clear_schedule\",\n ClearScheduledJobs = \"clear_scheduled_jobs\",\n ClearStoredSchedule = \"clear_stored_schedule\",\n ContributionPaid = \"contribution_paid\",\n Custom = \"custom\",\n GodchildAccepted = \"godchild_accepted\",\n GodchildRejected = \"godchild_rejected\",\n GodchildRequest = \"godchild_request\",\n LoginStuck = \"login_stuck\",\n NewPost = \"new_post\",\n PendingSignup = \"pending_signup\",\n RestoreSchedule = \"restore_schedule\",\n RestoreScheduleEager = \"restore_schedule_eager\",\n SaveSchedule = \"save_schedule\",\n ShotgunClosesSoon = \"shotgun_closes_soon\",\n ShotgunOpensSoon = \"shotgun_opens_soon\",\n ShowScheduledJobs = \"show_scheduled_jobs\",\n Test = \"test\",\n}\n", "export const STREAM_NAME = 'notella:stream';\nexport const SUBJECT_NAME = 'notella:notification';\nexport const CONSUMER_NAME = 'NotellaConsumer';"],
5
-
"mappings": ";AAmDO,IAAK,QAAL,kBAAKA,WAAL;AACH,EAAAA,OAAA,iBAAc;AACd,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,yBAAsB;AACtB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,YAAS;AACT,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,UAAO;AAnBC,SAAAA;AAAA,GAAA;;;ACnDL,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,gBAAgB;",
4
+
"sourcesContent": ["export interface Message {\n /**\n * URL to go to when the action button is clicked\n */\n action: string;\n /**\n * Additional action buttons\n */\n actions?: Action[];\n /**\n * Notification body\n */\n body: string;\n /**\n * Clear scheduled jobs for the object_id before scheduling notifications\n */\n clear_schedule: boolean;\n /**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\n event: Event;\n /**\n * Unique ID for the notification scheduling request.\n */\n id: string;\n /**\n * URL to an image to display in the notification\n */\n image?: string;\n /**\n * Churros ID of the ressource (the ticket, the post, the comment, etc)\n * Used to determine to whom the notification should be sent\n * For godchild_request, this is not a user id, but a godparent request id.\n */\n object_id: string;\n /**\n * When to push the notification\n */\n send_at: Date;\n /**\n * Notification title\n */\n title: string;\n}\n\nexport interface Action {\n action: string;\n label: string;\n}\n\n/**\n * Type of event that triggered the notification\n * next-line-generate event-enum-jsonschema-values\n */\nexport enum Event {\n BookingPaid = \"booking_paid\",\n ClearSchedule = \"clear_schedule\",\n ClearStoredSchedule = \"clear_stored_schedule\",\n ContributionPaid = \"contribution_paid\",\n Custom = \"custom\",\n GodchildAccepted = \"godchild_accepted\",\n GodchildRejected = \"godchild_rejected\",\n GodchildRequest = \"godchild_request\",\n LoginStuck = \"login_stuck\",\n NewPost = \"new_post\",\n PendingSignup = \"pending_signup\",\n RestoreSchedule = \"restore_schedule\",\n RestoreScheduleEager = \"restore_schedule_eager\",\n SaveSchedule = \"save_schedule\",\n ShotgunClosesSoon = \"shotgun_closes_soon\",\n ShotgunOpensSoon = \"shotgun_opens_soon\",\n ShowScheduledJobs = \"show_scheduled_jobs\",\n Test = \"test\",\n}\n", "export const STREAM_NAME = 'notella:stream';\nexport const SUBJECT_NAME = 'notella:notification';\nexport const CONSUMER_NAME = 'NotellaConsumer';"],
5
+
"mappings": ";AAuDO,IAAK,QAAL,kBAAKA,WAAL;AACH,EAAAA,OAAA,iBAAc;AACd,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,yBAAsB;AACtB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,YAAS;AACT,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,sBAAmB;AACnB,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,UAAO;AAlBC,SAAAA;AAAA,GAAA;;;ACvDL,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,gBAAgB;",
6
6
"names": ["Event"]
7
7
}
-1
typescript/lib.txt
-1
typescript/lib.txt
+4
-1
typescript/message.ts
+4
-1
typescript/message.ts
···
12
12
*/
13
13
body: string;
14
14
/**
15
+
* Clear scheduled jobs for the object_id before scheduling notifications
16
+
*/
17
+
clear_schedule: boolean;
18
+
/**
15
19
* Type of event that triggered the notification
16
20
* next-line-generate event-enum-jsonschema-values
17
21
*/
···
52
56
export enum Event {
53
57
BookingPaid = "booking_paid",
54
58
ClearSchedule = "clear_schedule",
55
-
ClearScheduledJobs = "clear_scheduled_jobs",
56
59
ClearStoredSchedule = "clear_stored_schedule",
57
60
ContributionPaid = "contribution_paid",
58
61
Custom = "custom",