0

I've registered a channel to send notifications to an endpoint when a user is updated via the Users watch mechanism.

When receiving a notification indicating a user has updated, I then retrieve the user's information via the Users get endpoint.

I tested this by changing a users Given name but it doesn't work as expected - the Given name returned by Users.get is the old name, if I call the endpoint again a few minutes later it is the new one.

The documentation doesn't explicitly say that it will be correct at the time the notification fires but it does seem quite odd to be told a change has occurred but there is no way of knowing what it was, or that it's actually happened yet.

Is there a way of delaying these notifications until the data is ready? Or knowing when the change is ready?

bdx
  • 3,316
  • 4
  • 32
  • 65

2 Answers2

0

In the G Suite Admin Help in the section How changes propagate to Google services it says changes could even take up to 24 hours.

Changing settings or performing tasks, such as managing mobile devices and users, are not always immediately reflected. Some changes can take up to 24 hours to take effect. Sometimes, you’ll see a warning message if there’s an expected delay.

As a workaround, you could save in a variable the name of the user before changing it, then when you receive the push notification, call the Users: get and verify if the name is still the same with the variable you previously created.

alberto vielma
  • 2,302
  • 2
  • 8
  • 15
0

Instead of delaying the notifications, you can add delay in processing them. You can store email ids of all the users for which you received notification and process them periodically every few minutes or hours according to your business requirement.

The problem with immediate processing is that you will receive multiple notifications if someone updates multiple fields in the user's profile. Foe example, if the first name, last name and email id are changed one after another, your backend will receive 3 notifications at almost the same time and it can lead to concurrency issues in your application processing logic.

dishant makwana
  • 1,029
  • 6
  • 13