File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { upsertContentRoute } from "./upsert-content.ts";
44import { upsertRegistrationsRoute } from "./upsert-registrations.ts" ;
55import { upsertScheduleRoute } from "./upsert-schedule.ts" ;
66import { getWebPushInfo } from "./web-push-info.ts" ;
7+ import { sendWebPushMessage } from "./web-push-send.ts" ;
78import { testWebPushMessage } from "./web-push-test.ts" ;
89
910export const adminRoutes = [
@@ -15,4 +16,5 @@ export const adminRoutes = [
1516
1617 getWebPushInfo ,
1718 testWebPushMessage ,
19+ sendWebPushMessage ,
1820] ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { WebPushRepo } from "../notifications/web-push-repo.ts";
44
55export const getWebPushInfo = defineRoute ( {
66 method : "GET" ,
7- pathname : "/admin/v1/conference /:conference/web-push" ,
7+ pathname : "/admin/v1/conferences /:conference/web-push/info " ,
88 dependencies : {
99 authz : useAuthz ,
1010 webPush : WebPushRepo . use ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const _Request = Structure.object({
1111
1212export const sendWebPushMessage = defineRoute ( {
1313 method : "POST" ,
14- pathname : "/admin/v1/conference /:conference/web-push-test " ,
14+ pathname : "/admin/v1/conferences /:conference/web-push/send " ,
1515 dependencies : {
1616 authz : useAuthz ,
1717 webPush : WebPushRepo . use ,
@@ -30,7 +30,9 @@ export const sendWebPushMessage = defineRoute({
3030 const body = await assertRequestBody ( _Request , request ) ;
3131
3232 // Get all of the web-push-devices for the conference
33- const devices = await webPush . listConferenceDevices ( conference . id ) ;
33+ const devices = await webPush . listConferenceDevices ( conference . id , [
34+ "Special" ,
35+ ] ) ;
3436
3537 // Send the message
3638 const stats = await _sendToDevices ( devices , webPush , {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const _Request = Structure.object({
1111
1212export const testWebPushMessage = defineRoute ( {
1313 method : "POST" ,
14- pathname : "/admin/v1/conference /:conference/web-push- test" ,
14+ pathname : "/admin/v1/conferences /:conference/web-push/ test" ,
1515 dependencies : {
1616 authz : useAuthz ,
1717 webPush : WebPushRepo . use ,
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ export class WebPushRepo {
192192
193193 const devices = await WebPushDeviceTable . select (
194194 this . sql ,
195- this . sql `id IN ${ this . sql ( registrations . map ( ( r ) => r . id ) ) } ` ,
195+ this . sql `registration_id IN ${ this . sql ( registrations . map ( ( r ) => r . id ) ) } ` ,
196196 ) ;
197197
198198 const categories = sumCategories ( devices ) ;
@@ -208,16 +208,19 @@ export class WebPushRepo {
208208 return { categories, messages } ;
209209 }
210210
211- async listConferenceDevices ( conferenceId : number ) {
211+ async listConferenceDevices ( conferenceId : number , categories : string [ ] ) {
212212 const registrations = await RegistrationTable . select (
213213 this . sql ,
214- this . sql ` conference_id = ${ conferenceId } ` ,
214+ this . sql `conference_id = ${ conferenceId } ` ,
215215 [ "id" ] ,
216216 ) ;
217217
218218 return WebPushDeviceTable . select (
219219 this . sql ,
220- this . sql `id IN ${ this . sql ( registrations . map ( ( r ) => r . id ) ) } ` ,
220+ this . sql `
221+ registration_id IN ${ this . sql ( registrations . map ( ( r ) => r . id ) ) }
222+ AND categories ? ${ this . sql ( categories ) }
223+ ` ,
221224 ) ;
222225 }
223226}
You can’t perform that action at this time.
0 commit comments