chore(tool): add the possibility to force the sieve script activation

This commit is contained in:
Hivert Quentin
2024-11-22 09:08:13 +01:00
parent 7f7c743976
commit ce86d14826
3 changed files with 19 additions and 8 deletions

View File

@@ -3954,7 +3954,7 @@ _Defaults_ stores all parameters that can be found in Preferences panel. So it g
autoreply to many others options.
user-preferences get|set|unset defaults|settings user key [value|-f filename] [-p credentialFile]
user-preferences get|set|unset defaults|settings user key [value|-f filename] [-p credentialFile [-F]]
* First argument is the action *get*, *set* or *unset*
* Second argument is parameter type *settings* or *defaults*
@@ -3962,7 +3962,8 @@ autoreply to many others options.
* Fourth argument *key* is the name of the parameters where to make the action
* If the action is *set*, you should provide either *value* as fifth argument or a file with the value inside with *-f* filename/path
* If the action is *set* or *unset* and the *key* concerns a sieve script (filter, vacation, forward...), you
should provide a credential file, a one-line file that contains "username:password" of an admin account of your imap/sieve server.
should provide a credential file, a one-line file that contains "username:password" of an admin account of your imap/sieve server. If you
want t oforce the sieve script activation add -F after.
As there is a lot of parameters, this documentation will not go into details for each one. To know what are
the key names and their value you should got to your database in table defined by _SOGoProfileURL_ in your sogo.conf.
@@ -3991,7 +3992,7 @@ sogo-tool user-preferences unset defaults user1 Forward -p /etc/sogo/cred
*set* action:
----
sogo-tool user-preferences set defaults user1 Forward '{"forwardAddress":["sogo-tests2@sogo.alinto"],"enabled":1,"keepCopy":0}' -p cred
sogo-tool user-preferences set defaults user1 Forward '{"forwardAddress":["sogo-tests2@sogo.alinto"],"enabled":1,"keepCopy":0}' -p cred -F
----
or create a json file which contains _{"forwardAddress":["sogo-tests2@sogo.alinto"],"enabled":1,"keepCopy":0}_ then:
----

View File

@@ -68,6 +68,7 @@ typedef enum
" -p credentialFile Specify the file containing the sieve admin credentials\n"
" The file should contain a single line:\n"
" username:password\n"
" -F force the activation of the sieve script in case external scripts. Must be the las targument after -p credentialsFile"
" Examples:\n"
" sogo-tool user-preferences get defaults janedoe SOGoLanguage\n"
" sogo-tool user-preferences unset settings janedoe Mail\n"
@@ -144,9 +145,19 @@ typedef enum
account = [folder lookupName: @"0" inContext: localContext acquire: NO];
[account setContext: localContext];
error = [account updateFiltersWithUsername: authname
andPassword: authpwd
forceActivation: NO];
if([[arguments lastObject] isEqualToString: @"-F"])
{
error = [account updateFiltersWithUsername: authname
andPassword: authpwd
forceActivation: YES];
}
else
{
error = [account updateFiltersWithUsername: authname
andPassword: authpwd
forceActivation: NO];
}
if (error)
return NO;
}

View File

@@ -114,8 +114,7 @@
if (count < max)
{
max -= count;
toolArguments = [arguments
subarrayWithRange: NSMakeRange (count, max)];
toolArguments = [arguments subarrayWithRange: NSMakeRange (count, max)];
[toolArguments retain];
}
}