mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-28 14:45:28 +00:00
(fix) strip attendees with no email and don't send IMIP when it's Outlook the EAS client
This commit is contained in:
@@ -43,6 +43,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#import <NGObjWeb/WOCoreApplication.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
#import <NGCards/iCalPerson.h>
|
||||
|
||||
#import <NGExtensions/NGBase64Coding.h>
|
||||
|
||||
@@ -59,8 +61,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <NGMime/NGMimeBodyPart.h>
|
||||
#import <NGMime/NGMimeFileData.h>
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
#import <NGMime/NGMimeType.h>
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
#import <NGMime/NGConcreteMimeType.h>
|
||||
#import <NGMail/NGMimeMessageParser.h>
|
||||
#import <NGMail/NGMimeMessageGenerator.h>
|
||||
|
||||
@@ -3201,6 +3204,7 @@ void handle_eas_terminate(int signum)
|
||||
NSData *new_from_header;
|
||||
NSDictionary *identity;
|
||||
NSString *fullName, *email;
|
||||
NGMimeType *contentType;
|
||||
NSArray *from;
|
||||
|
||||
const char *bytes;
|
||||
@@ -3216,6 +3220,40 @@ void handle_eas_terminate(int signum)
|
||||
message = [parser parsePartFromData: data];
|
||||
RELEASE(parser);
|
||||
|
||||
// If an EAS client is trying to send an invitation email (request or response), we make sure to
|
||||
// remove all attendees that have NO email addresses. Outlook 2016 (and likely other EAS clients)
|
||||
// do that when sending IMIP only to "newly added or deleted attendees" - existing attendees have
|
||||
// their email addresses stripped, while keeping the display name value.
|
||||
contentType = [message contentType];
|
||||
|
||||
if ([contentType isKindOfClass: [NGConcreteTextMimeType class]] &&
|
||||
[[[message contentType] subType] caseInsensitiveCompare: @"calendar"] == NSOrderedSame &&
|
||||
([[(NGConcreteTextMimeType *)[message contentType] method] caseInsensitiveCompare: @"request"] == NSOrderedSame ||
|
||||
[[(NGConcreteTextMimeType *)[message contentType] method] caseInsensitiveCompare: @"reply"] == NSOrderedSame))
|
||||
{
|
||||
NGMimeMessageGenerator *generator;
|
||||
iCalCalendar *calendar;
|
||||
iCalPerson *attendee;
|
||||
NSArray *attendees;
|
||||
iCalEvent *event;
|
||||
|
||||
calendar = [iCalCalendar parseSingleFromSource: [message body]];
|
||||
event = [[calendar events] lastObject];
|
||||
attendees = [event attendees];
|
||||
|
||||
for (i = [attendees count]-1; i >= 0; i--)
|
||||
{
|
||||
attendee = [attendees objectAtIndex: i];
|
||||
if (![attendee rfc822Email] || [[attendee rfc822Email] caseInsensitiveCompare: @"nomail"] == NSOrderedSame)
|
||||
[event removeFromAttendees: attendee];
|
||||
}
|
||||
|
||||
// We regenerate the data to use
|
||||
[message setBody: [[calendar versitString] dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
generator = [[[NGMimeMessageGenerator alloc] init] autorelease];
|
||||
data = [NSMutableData dataWithData: [generator generateMimeFromPart: message]];
|
||||
}
|
||||
|
||||
from = [message headersForKey: @"from"];
|
||||
|
||||
if (![from count] || ![self _isEMailValid: [[from objectAtIndex: 0] pureEMailAddress]] ||
|
||||
|
||||
@@ -797,6 +797,14 @@
|
||||
if ([object firstChildWithTag: @"X-SOGo-Send-Appointment-Notifications"])
|
||||
return;
|
||||
|
||||
// We never send IMIP inivitaton/deletion/update when the "initiator" is Outlook 2013/2016 over
|
||||
// the EAS protocol. That is because Outlook will always issue a SendMail command
|
||||
// with the meeting details (ie., IMIP message with METHOD:REQUEST) so there's
|
||||
// no need to send it twice. Moreover, Outlook users can also choose to NOT send
|
||||
// the IMIP messsage at all, so SOGo won't send one without user's consent
|
||||
if ([[context objectForKey: @"DeviceType"] isEqualToString: @"WindowsOutlook15"])
|
||||
return;
|
||||
|
||||
ownerUser = [SOGoUser userWithLogin: owner];
|
||||
dd = [ownerUser domainDefaults];
|
||||
if ([dd appointmentSendEMailNotifications] && [object isStillRelevant])
|
||||
|
||||
Reference in New Issue
Block a user