Fix freebusy data fetching of MS Exchange contacts

pull/228/head
Francis Lachapelle 2016-11-29 15:48:15 -05:00
parent e0b0a1d783
commit b27c868271
4 changed files with 38 additions and 12 deletions

1
NEWS
View File

@ -3,6 +3,7 @@
Bug fixes
- [web] fixed JavaScript exception when SOGo is launched from an external link (#3900)
- [web] restored fetching of freebusy information of MS Exchange contacts
3.2.3 (2016-11-25)
------------------

View File

@ -140,7 +140,7 @@ NSNumber *iCalDistantFutureNumber = nil;
[currentAttendee rfc822Email], @"email",
([[currentAttendee cnWithoutQuotes] length] ? [currentAttendee cnWithoutQuotes] : [currentAttendee rfc822Email]) , @"name",
nil];
if ((uid = [currentAttendee uid]))
if ((uid = [currentAttendee uidInContext: context]))
{
[attendeeData setObject: uid forKey: @"uid"];
}
@ -156,12 +156,12 @@ NSNumber *iCalDistantFutureNumber = nil;
if ([source conformsToProtocol: @protocol (SOGoDNSource)] &&
[[(NSObject <SOGoDNSource>*) source MSExchangeHostname] length])
{
uid = [NSString stringWithFormat: @"%@:%@", [[context activeUser] login],
[contactData valueForKey: @"c_uid"]];
[attendeeData setObject: uid forKey: @"uid"];
[attendeeData setObject: [NSNumber numberWithInt: 1] forKey: @"isMSExchange"];
[attendeeData setObject: [contactData valueForKey: @"c_uid"] forKey: @"uid"];
}
}
}
[attendeeData setObject: [[currentAttendee partStat] lowercaseString] forKey: @"partstat"];
[attendeeData setObject: [[currentAttendee role] lowercaseString] forKey: @"role"];
if ([[currentAttendee delegatedTo] length])

View File

@ -49,7 +49,9 @@
*/
Resource.prototype.userResource = function(uid) {
var path = _.compact(this._activeUser.folderURL.split('/'));
path.splice(path.length - 1, 1, escape(uid));
if (uid)
path.splice(path.length - 1, 1, escape(uid));
return new Resource(this._http, this._q, '/' + path.join('/'), this._activeUser);
};

View File

@ -618,8 +618,14 @@
// this.organizer.$image = Component.$gravatar(this.organizer.email, 32);
// }
// Load freebusy of attendees
this.updateFreeBusy();
if (this.attendees) {
_.forEach(this.attendees, function(attendee) {
attendee.image = Component.$gravatar(attendee.email, 32);
});
// Load freebusy of attendees
this.updateFreeBusy();
}
this.selected = false;
};
@ -774,7 +780,6 @@
if (this.attendees) {
_.forEach(this.attendees, function(attendee) {
attendee.image = Component.$gravatar(attendee.email, 32);
_this.updateFreeBusyAttendee(attendee);
});
}
@ -800,21 +805,37 @@
* @param {Object} card - an Card object instance of the attendee
*/
Component.prototype.updateFreeBusyAttendee = function(attendee) {
var params, url, days;
var resource, uid, params, days;
if (attendee.uid) {
uid = attendee.uid;
if (attendee.domain)
uid += '@' + attendee.domain;
params =
{
sday: this.start.getDayString(),
eday: this.end.getDayString()
};
url = ['..', '..', attendee.uid, 'freebusy.ifb'];
if (attendee.isMSExchange) {
// Attendee is not a local user, but her freebusy data is available from an external MS Exchange server;
// we query /SOGo/so/<login_user>/freebusy.ifb/ajaxRead?uid=<uid>
resource = Component.$$resource.userResource();
params.uid = uid;
}
else {
// Attendee is a user;
// web query /SOGo/so/<uid>/freebusy.ifb/ajaxRead
resource = Component.$$resource.userResource(uid);
}
days = _.map(this.start.daysUpTo(this.end), function(day) { return day.getDayString(); });
if (angular.isUndefined(attendee.freebusy))
attendee.freebusy = {};
// Fetch FreeBusy information
Component.$$resource.fetch(url.join('/'), 'ajaxRead', params).then(function(data) {
resource.fetch('freebusy.ifb', 'ajaxRead', params).then(function(data) {
_.forEach(days, function(day) {
var hour;
@ -893,11 +914,13 @@
else {
// Single contact
attendee = {
uid: card.c_uid,
domain: card.c_domain,
isMSExchange: card.ismsexchange,
name: card.c_cn,
email: card.$preferredEmail(),
role: 'req-participant',
partstat: 'needs-action',
uid: card.c_uid,
$avatarIcon: card.$avatarIcon
};
if (!_.find(this.attendees, function(o) {