mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-24 11:24:17 +00:00
feat(calendar): Add alarms for external users (wip)
This commit is contained in:
@@ -218,6 +218,7 @@
|
||||
alarms = [NSMutableArray arrayWithCapacity: max];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
entity = nil;
|
||||
record = [records objectAtIndex: count];
|
||||
|
||||
if (record && [record objectForKey: @"c_path"] && [[record objectForKey: @"c_path"] hasPrefix:@"EXTERNAL"]) {
|
||||
@@ -232,35 +233,32 @@
|
||||
{
|
||||
if (record && [record objectForKey: @"c_path"] && [[record objectForKey: @"c_path"] hasPrefix:@"EXTERNAL"]) {
|
||||
NSString *path;
|
||||
NSArray *parts;
|
||||
NSArray *parts, *entityAlarms;
|
||||
NSMutableDictionary *mRecord;
|
||||
iCalCalendar *calendar;
|
||||
|
||||
mRecord = [NSMutableDictionary dictionaryWithDictionary: record];
|
||||
parts = [[mRecord objectForKey: @"c_path"] componentsSeparatedByString:@":"];
|
||||
path = [parts objectAtIndex: 1];
|
||||
[mRecord setObject: path forKey: @"c_path"];
|
||||
container = [self _lookupContainerMatchingRecord: mRecord];
|
||||
[self _extractOwner: &owner
|
||||
|
||||
calendar = [self _lookupCalendarMatchingRecord: mRecord];
|
||||
entity = [self _lookupEntityMatchingRecord: mRecord inCalendar: calendar];
|
||||
|
||||
if (entity && calendar && [entity alarms] && [[entity alarms] count] > 0) {
|
||||
[self _extractOwner: &owner
|
||||
fromPath: [mRecord objectForKey: @"c_path"]];
|
||||
|
||||
// alarm = [iCalAlarm alarmForEvent: self
|
||||
// owner: owner
|
||||
// action: reminderAction
|
||||
// unit: reminderUnit
|
||||
// quantity: reminderQuantity
|
||||
// reference: reminderReference
|
||||
// reminderRelation: reminderRelation
|
||||
// emailAttendees: reminderEmailAttendees
|
||||
// emailOrganizer: reminderEmailOrganizer];
|
||||
|
||||
[alarms addObject: alarm];
|
||||
|
||||
[metadata addObject: [NSDictionary dictionaryWithObjectsAndKeys: owner, @"owner",
|
||||
mRecord, @"record",
|
||||
container, @"container",
|
||||
[NSNumber numberWithBool: YES], @"isExternal",
|
||||
[[parts objectAtIndex: 2] componentsSeparatedByString: @","], @"externalEmailList",
|
||||
nil]];
|
||||
[alarms addObject: [entityAlarms firstObject]];
|
||||
|
||||
[metadata addObject: [NSDictionary dictionaryWithObjectsAndKeys: owner, @"owner",
|
||||
record, @"record",
|
||||
container, @"container",
|
||||
[NSNumber numberWithBool: YES], @"isExternal",
|
||||
[[parts objectAtIndex: 2] componentsSeparatedByString: @","], @"externalEmailList",
|
||||
nil]];
|
||||
}
|
||||
} else {
|
||||
container = [self _lookupContainerMatchingRecord: record];
|
||||
[alarms addObject: alarm];
|
||||
@@ -268,6 +266,7 @@
|
||||
record, @"record",
|
||||
container, @"container",
|
||||
entity, @"entity",
|
||||
[NSNumber numberWithBool: NO], @"isExternal",
|
||||
nil]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@
|
||||
- (void) _processAlarm: (iCalAlarm *) alarm
|
||||
withOwner: (NSString *) ownerId
|
||||
andContainerPath: (NSString *) containerPath
|
||||
externalEmailAddresses: (NSArray *) externalEmailAddresses
|
||||
{
|
||||
NGMutableHashMap *headers;
|
||||
NSArray *parts;
|
||||
@@ -237,10 +238,15 @@
|
||||
subject = [p getSubject];
|
||||
|
||||
headers = [self _headersForAlarm: alarm withOwner: owner withSubject: subject];
|
||||
[self _sendMessageWithHeaders: headers
|
||||
if (!externalEmailAddresses) {
|
||||
[self _sendMessageWithHeaders: headers
|
||||
content: content
|
||||
to: [owner primaryIdentity]
|
||||
withMailer: mailer];
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void) usage
|
||||
@@ -311,9 +317,15 @@
|
||||
max = [alarms count];
|
||||
|
||||
for (count = 0; count < max; count++) {
|
||||
[self _processAlarm: [alarms objectAtIndex: count]
|
||||
if (![[[metadata objectAtIndex: count] objectForKey: @"isExternal"] boolValue]) {
|
||||
[self _processAlarm: [alarms objectAtIndex: count]
|
||||
withOwner: [[metadata objectAtIndex: count] objectForKey: @"owner"]
|
||||
andContainerPath: [[[metadata objectAtIndex: count] objectForKey: @"record"] objectForKey: @"c_path"]];
|
||||
} else {
|
||||
[self _processAlarmExternal: [alarms objectAtIndex: count]
|
||||
withOwner: [[metadata objectAtIndex: count] objectForKey: @"owner"]
|
||||
andContainerPath: [[[metadata objectAtIndex: count] objectForKey: @"record"] objectForKey: @"c_path"]];
|
||||
}
|
||||
}
|
||||
|
||||
// We now update the next alarm date (if any, for recurring
|
||||
|
||||
Reference in New Issue
Block a user