gustafn
committed
on 13 Dec 24
avoid triggering exception, when provided host header field cannot be resolved.
/tcl/apm-callback-procs.tcl (+63 -1)
6 6     @author Lars Pind (lars@collaboraid.biz)
7 7     @cvs-id $Id$
8 8 }
9 9
10 10 namespace eval notification::apm {}
11 11
12 12 ad_proc -private notification::apm::after_install {} {
13 13     After install callback.  Create service contracts.
14 14 } {
15 15     db_transaction {
16 16
17 17         # Create the delivery method service contract
18 18         create_delivery_method_contract
19 19
20 20         # Register email delivery method service contract implementation
21 21         set impl_id [create_email_delivery_method_impl]
22 22
23 23         # Register the service contract implementation with the notifications service
24 24         register_email_delivery_method -impl_id $impl_id
25 25
  26         # Register sse delivery method service contract implementation
  27         set impl_id [create_sse_delivery_method_impl]
  28
  29         # Register the service contract implementation with the notifications service
  30         register_sse_delivery_method -impl_id $impl_id
  31
26 32         # Create the notification type service contract
27 33         create_notification_type_contract
28 34     }
29 35 }
30 36
31 37 ad_proc -private notification::apm::before_uninstall {} {
32 38     Before uninstall callback.  Get rid of service contracts.
33 39 } {
34 40     db_transaction {
35 41
36 42         # Delete the notification type service contract
37 43         delete_notification_type_contract
38 44
39 45         # Delete the service contract implementation from the notifications service
40 46         unregister_email_delivery_method
41 47
42 48         # Unregister email delivery method service contract implementation
43 49         delete_email_delivery_method_impl
44 50
  51         # Delete the service contract implementation from the notifications service
  52         unregister_sse_delivery_method
  53
  54         # Unregister sse delivery method service contract implementation
  55         delete_sse_delivery_method_impl
  56
45 57         # Delete the delivery method service contract
46 58         delete_delivery_method_contract
47 59
48 60     }
49 61 }
50 62
51 63 ad_proc -private notification::apm::after_upgrade {
52 64     {-from_version_name:required}
53 65     {-to_version_name:required}
54 66 } {
55 67     After upgrade callback.
56 68 } {
57 69     apm_upgrade_logic \
58 70         -from_version_name $from_version_name \
59 71         -to_version_name $to_version_name \
60 72         -spec {
61 73             5.1.0d1 5.1.0d2 {
62 74                 db_transaction {
63 75
64 76                     # Delete and recreate contract
 
89 101                     delete_delivery_method_contract
90 102                     create_delivery_method_contract
91 103
92 104                     # The old implementation is still there, but now it's unbound
93 105
94 106                     # Now change the name of the old implementation
95 107                     db_dml update { update acs_sc_impls set impl_name = 'notification_email_old' where impl_name = 'notification_email' }
96 108                     db_dml update { update acs_sc_impl_aliases set impl_name = 'notification_email_old' where impl_name = 'notification_email' }
97 109
98 110                     # Create the new implementation
99 111                     set impl_id [create_email_delivery_method_impl]
100 112
101 113                     # Register the new impl ID with notification_delivery_methods
102 114                     update_email_delivery_method_impl -impl_id $impl_id
103 115
104 116                     # Delete the old implementation
105 117                     delete_email_delivery_method_impl -impl_name "notification_email_old"
106 118
107 119                 }
108 120             }
  121             5.10.1 6.0.0d1 {
  122                 db_transaction {
  123
  124                     # Register sse delivery method service contract implementation
  125                     set impl_id [create_sse_delivery_method_impl]
  126
  127                     # Register the service contract implementation with the notifications service
  128                     register_sse_delivery_method -impl_id $impl_id
  129
109 130                 }
110 131             }
  132         }
  133 }
111 134
112 135
113 136 ad_proc -private notification::apm::create_delivery_method_contract {} {
114 137     Create the delivery method service contract.
115 138 } {
116 139     acs_sc::contract::new_from_spec \
117 140         -spec {
118 141             name "NotificationDeliveryMethod"
119 142             description "Notification Delivery Method"
120 143             operations {
121 144                 Send {
122 145                     description "Send a notification"
123 146                     input {
124 147                         from_user_id:integer
125 148                         to_user_id:integer
126 149                         reply_object_id:integer
127 150                         notification_type_id:integer
128 151                         subject:string
129 152                         content_text:string
130 153                         content_html:string
 
166 189     Unregister the NotificationDeliveryMethod service contract implementation for email.
167 190 } {
168 191     acs_sc::impl::delete \
169 192         -contract_name "NotificationDeliveryMethod" \
170 193         -impl_name $impl_name
171 194 }
172 195
173 196 ad_proc -private notification::apm::register_email_delivery_method {
174 197     -impl_id:required
175 198 } {
176 199     Register the email delivery method with the notifications service.
177 200
178 201     @param impl_id The ID of the NotificationDeliveryMethod service contract implementation.
179 202 } {
180 203     notification::delivery::new \
181 204         -sc_impl_id $impl_id \
182 205         -short_name "email" \
183 206         -pretty_name "Email"
184 207 }
185 208
  209 ad_proc -private notification::apm::create_sse_delivery_method_impl {} {
  210     Register the service contract implementation and return the impl_id
  211
  212     @return impl_id of the created implementation
  213 } {
  214     return [acs_sc::impl::new_from_spec -spec {
  215         contract_name "NotificationDeliveryMethod"
  216         name "notification_sse"
  217         owner "notifications"
  218         aliases {
  219             Send notification::sse::send
  220             ScanReplies notification::sse::scan_replies
  221         }
  222     }]
  223 }
  224
  225 ad_proc -private notification::apm::delete_sse_delivery_method_impl {
  226     {-impl_name "notification_sse"}
  227 } {
  228     Unregister the NotificationDeliveryMethod service contract implementation for sse.
  229 } {
  230     acs_sc::impl::delete \
  231         -contract_name "NotificationDeliveryMethod" \
  232         -impl_name $impl_name
  233 }
  234
  235 ad_proc -private notification::apm::register_sse_delivery_method {
  236     -impl_id:required
  237 } {
  238     Register the sse delivery method with the notifications service.
  239
  240     @param impl_id The ID of the NotificationDeliveryMethod service contract implementation.
  241 } {
  242     notification::delivery::new \
  243         -sc_impl_id $impl_id \
  244         -short_name "sse" \
  245         -pretty_name "Server-sent Events"
  246 }
  247
186 248 ad_proc -private notification::apm::update_email_delivery_method_impl {
187 249     -impl_id:required
188 250 } {
189 251     Register the email delivery method with the notifications service.
190 252
191 253     @param impl_id The ID of the NotificationDeliveryMethod service contract implementation.
192 254 } {
193 255     set delivery_method_id [notification::delivery::get_id -short_name "email"]
194 256
195 257     notification::delivery::update_sc_impl_id \
196 258         -delivery_method_id $delivery_method_id \
197 259         -sc_impl_id $impl_id
198 260 }
199 261
200 262 ad_proc -private notification::apm::unregister_email_delivery_method {} {
201 263     Unregister the service contract delivery method with the notifications service.
202 264 } {
203 265     set delivery_method_id [notification::delivery::get_id -short_name "email"]
204 266
205 267     notification::delivery::delete \