[Home]

Summary:ASTERISK-16582: [patch] Merging events for Exchange web service doesn't work as expected, resulting in only one event in calendar
Reporter:Bc. Jan Kaláb (pitel)Labels:
Date Opened:2010-08-17 07:14:01Date Closed:2010-09-14 01:58:45
Priority:BlockerRegression?No
Status:Closed/CompleteComponents:Resources/res_calendar
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) ews_events.patch
( 1) mergedebug.patch
Description:I just noticed that when I have multiple events in EWS calendar, only one is merged. And I found a strange behaviour of ast_calendar_merge_events().

I added a little debug output (in attached patch) and get this result:

-- AQAPAHRlc3RmaXRAaXBleC5jegBGAAADyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAx0AAABc2kyxph+ESpyNgxlJiF/xAAABHppPAAAA: AAA
++ AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQu2RRQAAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAdAXzuHYsTEahylQnDZcWqAAPO7o49gAAEA==: BBB
-- AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQu2RRQAAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAdAXzuHYsTEahylQnDZcWqAAPO7o49gAAEA==: BBB
++ AQAPAHRlc3RmaXRAaXBleC5jegBGAAADyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAx0AAABc2kyxph+ESpyNgxlJiF/xAAABHppPAAAA: AAA

-- in beggining of line means the event is removed from our internal calendat, ++ means it was added and there should be also == which means it was merged. Every action follows by UID of event, colon and name of event.

As you can, the event AAA is removed, event BBB is added, then removed and then is event AAA added again, resulting in only event AAA being in internal calendar.

I really don't know why is this happening, since UID is compared with known events, and then is decided if we know if this event already exist or not. And appereantly, the UIDs match, so I have really no idea why it results in removing and adding the same event instead of merging.

And just for infomration, icalendar modul works as expected, merging already known events.
Comments:By: Leif Madsen (lmadsen) 2010-08-17 15:53:19

Would you like commit access so you can resolve these types of issues yourself? I understand this particular issue has a debugging patch and not a solution patch, but a couple of your other calendar patches could likely go in after a code review.

By: Bc. Jan Kaláb (pitel) 2010-08-18 03:47:18

Well, it might speed the thing up, since Terry is probably on vacation or something like that.

I'd just like to know how should I use code review.

By: Bc. Jan Kaláb (pitel) 2010-08-18 04:31:02

Solved! :)

Probably when adding support for attendees, someone changed the logic of getting  events, dispatching new request for every event, resulting in getting multiple callbacks of </Envelope> XML elements. This caused mering only one event each time, instead of all known events.

Solution: add counter to know how many events has already been acquired and merge only if we have all.

Result:
//First check (add all new events)
++ AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQx/b33AAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAdAXzuHYsTEahylQnDZcWqAAPO7o49gAAEA==: AAA
++ AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQx/b33AAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAXNpMsaYfhEqcjYMZSYhf8QAAAA59CQAAEA==: BBB
++ AQAPAHRlc3RmaXRAaXBleC5jegBGAAADyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAx0AAABc2kyxph+ESpyNgxlJiF/xAAABHppQAAAA: CCC

//Another check (merge events)
== AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQx/b33AAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAdAXzuHYsTEahylQnDZcWqAAPO7o49gAAEA==: AAA
== AAAPAHRlc3RmaXRAaXBleC5jegFRAAgIzQx/b33AAEYAAAAAyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAAAAHQAAXNpMsaYfhEqcjYMZSYhf8QAAAA59CQAAEA==: BBB
== AQAPAHRlc3RmaXRAaXBleC5jegBGAAADyTdZ3ABu8EOjYAFhV6KsHgcA+GG41xCdl025mKVi8islNgAAAx0AAABc2kyxph+ESpyNgxlJiF/xAAABHppQAAAA: CCC

Special bonus: Moved XML start element debug message to level 5 (the same as XML end).

By: Leif Madsen (lmadsen) 2010-08-23 17:50:50

pitel: awesome -- it'd probably be easiest for you to jump on IRC and join #asterisk-dev and speak with jpeeler about getting a certificate so you can do commits, and to speak with the developers about your first round of commits. This way people can help you move through the review process and make sure you get a Ship It! and then perform your commits to 1.8 and trunk.

Thanks!

By: Terry Wilson (twilson) 2010-09-07 10:49:20

pitel: You can go ahead and commit this fix and close the issue (and the other calendaring issues you have patches for as well).

By: Bc. Jan Kaláb (pitel) 2010-09-07 16:02:33

I'm now on vacation, I'll be glad to do it when I return home at the end of this week.

By: Bc. Jan Kaláb (pitel) 2010-09-11 14:52:29

Code review: https://reviewboard.asterisk.org/r/916

By: Digium Subversion (svnbot) 2010-09-14 01:55:45

Repository: asterisk
Revision: 286617

U   branches/1.8/res/res_calendar_ews.c

------------------------------------------------------------------------
r286617 | pitel | 2010-09-14 01:55:44 -0500 (Tue, 14 Sep 2010) | 7 lines

Merging events for Exchange web service doesn't work as expected, resulting in only one event in calendar

The solution is to use "global" counter of events, since we do new requests for every event and calendar sync after every request. So now we do sync only after last request.

(closes issue ASTERISK-16582)
Review: https://reviewboard.asterisk.org/r/916/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=286617

By: Digium Subversion (svnbot) 2010-09-14 01:58:44

Repository: asterisk
Revision: 286618

_U  trunk/
U   trunk/res/res_calendar_ews.c

------------------------------------------------------------------------
r286618 | pitel | 2010-09-14 01:58:44 -0500 (Tue, 14 Sep 2010) | 14 lines

Merged revisions 286617 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
 r286617 | pitel | 2010-09-14 08:55:44 +0200 (?\195?\154t, 14 z?\195?\161?\197?\153 2010) | 7 lines
 
 Merging events for Exchange web service doesn't work as expected, resulting in only one event in calendar
 
 The solution is to use "global" counter of events, since we do new requests for every event and calendar sync after every request. So now we do sync only after last request.
 
 (closes issue ASTERISK-16582)
 Review: https://reviewboard.asterisk.org/r/916/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=286618