Does anyone know if Subscriptions are supposed to ...
# general
b
Does anyone know if Subscriptions are supposed to work with User or Login resource types?
n
This is the main server code that creates & updates resources https://github.com/medplum/medplum/blob/7fdb50c28e8211733ef69b7d9a20cae67d3d2a07/packages/server/src/fhir/repo.ts#L466-L532 It calls
addBackgroundJobs -> addSubscriptionJobs
which only has a clause preventing Subscription execution for `AuditEvent`'s (likely to prevent execution loop) https://github.com/medplum/medplum/blob/7fdb50c28e8211733ef69b7d9a20cae67d3d2a07/packages/server/src/workers/subscription.ts#L146-L150
b
Thanks @node5585 for the pointer. That looks promising. Now to figure out why a Subscription isn't firing on User or Login resources. 🙂
r
Hi @bnapora - User and Login resoruces are only accessible by SuperAdmins. So it could be the case that your Subscriptions are not in the SuperAdmin project, and therefore cannot be triggered by them
b
@rahul1 Thx for suggestion. Subscriptions are in Super Admin. When User is updated, a Subscription event is triggered. It looks like Subscriptions are just not firing when the resource is first created. When a user is created either with
startNewUser
or
startGoogleLogin
a User resource is created, but no Subscription event fires. Do you think this is intentional?
@rahul1 @node5585 I figured out the issue. When a User resource is created using
startGoogleLogin
(possibly others), the resource is created WITHOUT a
meta.project
value. It does have a
project.reference
value. The
getSubscriptions
method is only checking for subscriptions if there is a value in
meta.project
field. If no value, then no subscriptions retrieved. If User resources is "edited" in Admin app, then a
meta.project
value is added to the User resource, and a subscription is triggered. I will create an issue.
144 Views