Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EWS ruby viewpoint batch subscribe push notifications

I'm using viewpoint gem to subscribe to microsoft exchange notification service. So far I managed to subscribe to a single folder by using subscribe method in this: https://github.com/WinRb/Viewpoint/blob/bcda30abdab99f52270f2c24a1c78364c986d967/lib/ews/soap/exchange_notification.rb

I tried passing multiple hashes with different folder ids that belong to different accounts on the same server.

client.ews.subscribe(
[{ :push_subscription_request => {
  :folder_ids =>  [{id: calendar[:id], change_key: calendar[:change_key]}],
  :subscribe_to_all_folders => true,
  :event_types=>  %w{CopiedEvent CreatedEvent DeletedEvent MovedEvent},
  :status_frequency => 1,
  :uRL => 'https://51.ngrok.io/ews_watch',
}, 
{same again with different calendar ids}]
)

I get the responses from ews, but only for a single calendar folder.

Does anyone know how to batch subscribe to multiple mailboxes on the same server so that I would receive a batch push notification from ews server instead of getting one for each subscription ?

Thank you

like image 583
Richardlonesteen Avatar asked Nov 09 '22 02:11

Richardlonesteen


1 Answers

I would iterate through it. Depending on where the ID's are stored:

@client.ews.subscribe.each do |ces| 
ces([{ :push_subscription_request => {
  :folder_ids =>  [{id: calendar[:id], change_key: calendar[:change_key]}],
  :subscribe_to_all_folders => true,
  :event_types=>  %w{CopiedEvent CreatedEvent DeletedEvent MovedEvent},
  :status_frequency => 1,
  :uRL => 'https://51.ngrok.io/ews_watch',
}])
end

Not testeted, but this should do the trick. Just iterate over the ID's.

like image 180
CottonEyeJoe Avatar answered Nov 15 '22 05:11

CottonEyeJoe