You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(custom events): full JWT integration for OSCustomEventsExecutor
Mirrors the JWT-aware pattern of OSPropertyOperationExecutor so custom
events behave consistently with the other user-scoped executors:
- Executor init now takes jwtConfig: OSUserJwtConfig and subscribes as
an OSUserJwtConfigListener.
- uncacheDeltas / uncacheRequests drop entries whose identity model has
no externalId when JWT is required, and load pendingAuthRequests from
the new persistence key.
- processDeltaQueue is gated on jwtConfig.isRequired being known, and
drops in-flight deltas for JWT-required users without externalId.
- executeRequest checks addJWTHeaderIsValid; on failure it pends the
request via pendRequestUntilAuthUpdated. 401 responses trigger
handleUnauthorizedError, which invalidates the JWT and pends the
request for retry when the JWT updates.
- onRequiresUserAuthChanged drops invalid in-flight deltas/requests
when auth turns on; onJwtUpdated re-queues this externalId's pending
requests.
Request-level: OSRequestCustomEvents.prepareForExecution no longer
checks JWT inline (now handled by the executor before prepareForExecution),
matching the OSRequestUpdateProperties shape. Renamed the call from the
non-existent addPushSubscriptionIdToAdditionalHeaders to the branch's
addPushSubscriptionToAdditionalHeaders.
Adds OS_CUSTOM_EVENTS_EXECUTOR and OS_CUSTOM_EVENTS_EXECUTOR_PENDING_QUEUE_KEY
constants. Updates OneSignalUserManagerImpl to pass jwtConfig at init,
and the test mock to do likewise.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
OneSignalLog.onesignalLog(.LL_ERROR, message:"OSCustomEventsExecutor error encountered reading from cache for \(OS_CUSTOM_EVENTS_EXECUTOR_REQUEST_QUEUE_KEY)")
101
-
self.requestQueue =[]
102
105
}
106
+
107
+
// Hook each uncached Request to the model in the store
OneSignalLog.onesignalLog(.LL_DEBUG, message:"OSCustomEventsExecutor processDeltaQueueWithBatching returning early due to requiresAuth: \(String(describing: jwtConfig.isRequired))")
152
+
return
153
+
}
154
+
122
155
self.dispatchQueue.async{
123
156
ifself.deltaQueue.isEmpty {
124
157
// Delta queue is empty but there may be pending requests
@@ -140,6 +173,13 @@ class OSCustomEventsExecutor: OSOperationExecutor {
140
173
continue
141
174
}
142
175
176
+
// If JWT is on but the external ID does not exist, drop this Delta
// This should not happen as there are preventative typing measures before this step
145
185
OneSignalLog.onesignalLog(.LL_ERROR, message:"OSCustomEventsExecutor.processDeltaQueue dropped due to invalid properties: \(delta)")
@@ -181,6 +221,11 @@ class OSCustomEventsExecutor: OSOperationExecutor {
181
221
}
182
222
183
223
func processDeltaQueue(inBackground:Bool){
224
+
guard jwtConfig.isRequired !=nilelse{
225
+
OneSignalLog.onesignalLog(.LL_DEBUG, message:"OSCustomEventsExecutor processDeltaQueue returning early due to requiresAuth: \(String(describing: jwtConfig.isRequired))")
226
+
return
227
+
}
228
+
184
229
self.dispatchQueue.async{
185
230
ifself.deltaQueue.isEmpty {
186
231
// Delta queue is empty but there may be pending requests
@@ -198,6 +243,13 @@ class OSCustomEventsExecutor: OSOperationExecutor {
198
243
continue
199
244
}
200
245
246
+
// If JWT is on but the external ID does not exist, drop this Delta
0 commit comments