chore(sogo-ealarms-notify): improve arguments parsing

Fixes #5197
pull/289/head
Francis Lachapelle 2020-11-11 11:58:30 -05:00
parent c600aa261c
commit 64f0519f7b
3 changed files with 24 additions and 10 deletions

View File

@ -42,7 +42,7 @@
+ (SOGoMailer *) mailerWithDomainDefaults: (SOGoDomainDefaults *) dd; + (SOGoMailer *) mailerWithDomainDefaults: (SOGoDomainDefaults *) dd;
- (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd; - (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd;
- (BOOL) requiresAuthentication;
- (NSException *) sendMailData: (NSData *) data - (NSException *) sendMailData: (NSData *) data
toRecipients: (NSArray *) recipients toRecipients: (NSArray *) recipients
sender: (NSString *) sender sender: (NSString *) sender

View File

@ -181,6 +181,11 @@
[super dealloc]; [super dealloc];
} }
- (BOOL) requiresAuthentication
{
return ![mailingMechanism isEqualToString: @"sendmail"] && authenticationType;
}
- (NSException *) _sendmailSendData: (NSData *) mailData - (NSException *) _sendmailSendData: (NSData *) mailData
toRecipients: (NSArray *) recipients toRecipients: (NSArray *) recipients
sender: (NSString *) sender sender: (NSString *) sender

View File

@ -168,6 +168,13 @@
owner = [SOGoUser userWithLogin: ownerId]; owner = [SOGoUser userWithLogin: ownerId];
mailer = [SOGoMailer mailerWithDomainDefaults: [owner domainDefaults]]; mailer = [SOGoMailer mailerWithDomainDefaults: [owner domainDefaults]];
if (!staticAuthenticator && [mailer requiresAuthentication])
{
fprintf (stderr, "Specify the file containing credentials to use for SMTP AUTH.\n"
"Use -h for help.\n");
return;
}
localContext = [WOContext context]; localContext = [WOContext context];
[localContext setActiveUser: owner]; [localContext setActiveUser: owner];
app = [[WOApplication alloc] initWithName: @"SOGo"]; app = [[WOApplication alloc] initWithName: @"SOGo"];
@ -177,7 +184,7 @@
[rm release]; [rm release];
[app _setCurrentContext:localContext]; [app _setCurrentContext:localContext];
userFolder = [[localContext activeUser] homeFolderInContext: localContext ]; userFolder = [[localContext activeUser] homeFolderInContext: localContext];
folders = [userFolder privateCalendars: @"Calendar" folders = [userFolder privateCalendars: @"Calendar"
inContext: localContext]; inContext: localContext];
@ -221,26 +228,28 @@
- (BOOL) run - (BOOL) run
{ {
NSArray *arguments, *alarms;
NSCalendarDate *startDate, *toDate; NSCalendarDate *startDate, *toDate;
SOGoEMailAlarmsManager *eaMgr;
NSMutableArray *metadata;
iCalEntityObject *entity;
SOGoCredentialsFile *cf;
NSString *credsFilename;
NSDictionary *d; NSDictionary *d;
NSArray *alarms; NSMutableArray *metadata;
NSString *credsFilename;
SOGoCredentialsFile *cf;
SOGoEMailAlarmsManager *eaMgr;
iCalEntityObject *entity;
int count, max; int count, max;
[[SOGoProductLoader productLoader] loadAllProducts: NO]; [[SOGoProductLoader productLoader] loadAllProducts: NO];
if ([[NSUserDefaults standardUserDefaults] stringForKey: @"h"]) arguments = [[NSProcessInfo processInfo] arguments];
credsFilename = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
if ([arguments count] > 1 && ([[arguments objectAtIndex: 1] isEqualToString: @"-h"] || !credsFilename))
{ {
[self usage]; [self usage];
return YES; return YES;
} }
credsFilename = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
if (credsFilename) if (credsFilename)
{ {
cf = [SOGoCredentialsFile credentialsFromFile: credsFilename]; cf = [SOGoCredentialsFile credentialsFromFile: credsFilename];