Add option to specify a particular IMAP folder (aka "label" in Gmail) (#477)

This commit is contained in:
Evil McJerkface
2020-11-22 06:39:39 -06:00
committed by GitHub
parent b6ec5e108b
commit 1346dd3616
20 changed files with 42 additions and 6 deletions
@@ -312,6 +312,7 @@ public class AppResource extends BaseResource {
* @apiSuccess {String} port IMAP port
* @apiSuccess {String} username IMAP username
* @apiSuccess {String} password IMAP password
* @apiSuccess {String} folder IMAP folder
* @apiSuccess {String} tag Tag for created documents
* @apiError (client) ForbiddenError Access denied
* @apiPermission admin
@@ -335,6 +336,7 @@ public class AppResource extends BaseResource {
Config portConfig = configDao.getById(ConfigType.INBOX_PORT);
Config usernameConfig = configDao.getById(ConfigType.INBOX_USERNAME);
Config passwordConfig = configDao.getById(ConfigType.INBOX_PASSWORD);
Config folderConfig = configDao.getById(ConfigType.INBOX_FOLDER);
Config tagConfig = configDao.getById(ConfigType.INBOX_TAG);
JsonObjectBuilder response = Json.createObjectBuilder();
@@ -361,6 +363,11 @@ public class AppResource extends BaseResource {
} else {
response.add("password", passwordConfig.getValue());
}
if (folderConfig == null) {
response.addNull("folder");
} else {
response.add("folder", folderConfig.getValue());
}
if (tagConfig == null) {
response.addNull("tag");
} else {
@@ -393,6 +400,7 @@ public class AppResource extends BaseResource {
* @apiParam {Integer} port IMAP port
* @apiParam {String} username IMAP username
* @apiParam {String} password IMAP password
* @apiParam {String} folder IMAP folder
* @apiParam {String} tag Tag for created documents
* @apiError (client) ForbiddenError Access denied
* @apiError (client) ValidationError Validation error
@@ -404,6 +412,7 @@ public class AppResource extends BaseResource {
* @param portStr IMAP port
* @param username IMAP username
* @param password IMAP password
* @param folder IMAP folder
* @param tag Tag for created documents
* @return Response
*/
@@ -416,6 +425,7 @@ public class AppResource extends BaseResource {
@FormParam("port") String portStr,
@FormParam("username") String username,
@FormParam("password") String password,
@FormParam("folder") String folder,
@FormParam("tag") String tag) {
if (!authenticate()) {
throw new ForbiddenClientException();
@@ -443,6 +453,9 @@ public class AppResource extends BaseResource {
if (!Strings.isNullOrEmpty(password)) {
configDao.update(ConfigType.INBOX_PASSWORD, password);
}
if (!Strings.isNullOrEmpty(folder)) {
configDao.update(ConfigType.INBOX_FOLDER, folder);
}
if (!Strings.isNullOrEmpty(tag)) {
configDao.update(ConfigType.INBOX_TAG, tag);
}