mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Add option to specify a particular IMAP folder (aka "label" in Gmail) (#477)
This commit is contained in:
parent
b6ec5e108b
commit
1346dd3616
@ -42,6 +42,7 @@ public enum ConfigType {
|
||||
INBOX_PORT,
|
||||
INBOX_USERNAME,
|
||||
INBOX_PASSWORD,
|
||||
INBOX_FOLDER,
|
||||
INBOX_TAG,
|
||||
INBOX_AUTOMATIC_TAGS,
|
||||
INBOX_DELETE_IMPORTED,
|
||||
|
@ -97,7 +97,7 @@ public class InboxService extends AbstractScheduledService {
|
||||
} catch (FolderClosedException e) {
|
||||
// Ignore this, we will just continue importing on the next cycle
|
||||
} catch (Exception e) {
|
||||
log.error("Error synching the inbox", e);
|
||||
log.error("Error syncing the inbox", e);
|
||||
lastSyncError = e.getMessage();
|
||||
} finally {
|
||||
try {
|
||||
@ -181,7 +181,7 @@ public class InboxService extends AbstractScheduledService {
|
||||
store.connect(ConfigUtil.getConfigStringValue(ConfigType.INBOX_USERNAME),
|
||||
ConfigUtil.getConfigStringValue(ConfigType.INBOX_PASSWORD));
|
||||
|
||||
Folder inbox = store.getFolder("INBOX");
|
||||
Folder inbox = store.getFolder(ConfigUtil.getConfigStringValue(ConfigType.INBOX_FOLDER));
|
||||
inbox.open(Folder.READ_WRITE);
|
||||
return inbox;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
db.version=26
|
||||
db.version=27
|
@ -0,0 +1,2 @@
|
||||
insert into T_CONFIG(CFG_ID_C, CFG_VALUE_C) values('INBOX_FOLDER', 'INBOX');
|
||||
update T_CONFIG set CFG_VALUE_C = '27' where CFG_ID_C = 'DB_VERSION';
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=26
|
||||
db.version=27
|
@ -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);
|
||||
}
|
||||
|
@ -427,6 +427,7 @@
|
||||
"port": "IMAP Port (143 oder 993)",
|
||||
"username": "IMAP Benutzername",
|
||||
"password": "IMAP Passwort",
|
||||
"folder": "IMAP Ordner",
|
||||
"tag": "Folgenden Tag zu importierten Dokumenten hinzufügen",
|
||||
"test": "Konfiguration testen",
|
||||
"last_sync": "Letzte Synchronisation: {{ data.date | date: 'medium' }}, {{ data.count }} E-Mail(s){{ data.count > 1 ? 's' : '' }} importiert",
|
||||
|
@ -441,6 +441,7 @@
|
||||
"port": "IMAP θύρα (143 ή 993)",
|
||||
"username": "IMAP όνομα χρήστη",
|
||||
"password": "IMAP κωδικός",
|
||||
"folder": "IMAP φάκελο",
|
||||
"tag": "Ετικέτα που προστέθηκε σε ειχερχόμενα έγγραφα",
|
||||
"test": "Δοκιμή μαραμέτρων",
|
||||
"last_sync": "Τελευταίος συγχρονισμός: {{ data.date | date: 'medium' }}, {{ data.count }} μήνυμα εισήχθη",
|
||||
|
@ -441,6 +441,7 @@
|
||||
"port": "IMAP port (143 or 993)",
|
||||
"username": "IMAP username",
|
||||
"password": "IMAP password",
|
||||
"folder": "IMAP folder",
|
||||
"tag": "Tag added to imported documents",
|
||||
"test": "Test the parameters",
|
||||
"last_sync": "Last synchronization: {{ data.date | date: 'medium' }}, {{ data.count }} message{{ data.count > 1 ? 's' : '' }} imported",
|
||||
|
@ -416,6 +416,7 @@
|
||||
"port": "Puerto IMAP (143 o 993)",
|
||||
"username": "Usuario IMAP",
|
||||
"password": "Contraseña IMAP",
|
||||
"folder": "Carpeta IMAP",
|
||||
"tag": "Etiqueta añadida a documentos importado",
|
||||
"test": "Comprobar parámetros",
|
||||
"last_sync": "Última sincronización: {{ data.date | date: 'medium' }}, {{ data.count }} mensaje{{ data.count > 1 ? 's' : '' }} importado{{ data.count > 1 ? 's' : '' }}",
|
||||
|
@ -430,6 +430,7 @@
|
||||
"port": "Port IMAP (143 ou 993)",
|
||||
"username": "Nom d'utilisateur IMAP",
|
||||
"password": "Mot de passe IMAP",
|
||||
"folder": "Dossier IMAP",
|
||||
"tag": "Tag ajouté aux documents importés",
|
||||
"test": "Tester les paramètres",
|
||||
"last_sync": "Dernière synchronisation : {{ data.date | date: 'medium' }}, {{ data.count }} message{{ data.count> 1 ? 's' : '' }} importé{{ data.count> 1 ? 's' : '' }}",
|
||||
|
@ -441,6 +441,7 @@
|
||||
"port": "Porta IMAP (143 o 993)",
|
||||
"username": "Nome utente IMAP",
|
||||
"password": "Password IMAP",
|
||||
"folder": "Cartella IMAP",
|
||||
"tag": "Tag aggiunti a documenti importati",
|
||||
"test": "Testa i parametri",
|
||||
"last_sync": "Ultima sincronizzazione: {{ data.date | date: 'medium' }}, {{ data.count }} messaggi{{ data.count > 1 ? '' : 'o' }} importat{{ data.count > 1 ? 'i' : 'o' }}",
|
||||
|
@ -441,6 +441,7 @@
|
||||
"port": "Port IMAP (143 or 993)",
|
||||
"username": "Użytkownik IMAP",
|
||||
"password": "Hasło IMAP",
|
||||
"folder": "Folderze IMAP",
|
||||
"tag": "Etykieta dodawana do za zaimportowanych dokumentów",
|
||||
"test": "Przetestuj połączenie",
|
||||
"last_sync": "Ostatnia synchronizacja: {{ data.date | date: 'medium' }}, {{ data.count }} zaimportowano {{ data.count > 1 ? 's' : '' }} dokumentów",
|
||||
|
@ -369,6 +369,7 @@
|
||||
"port": "Порт IMAP (143 или 993)",
|
||||
"username": "Имя пользователя IMAP",
|
||||
"password": "Пароль IMAP",
|
||||
"folder": "Папке IMAP",
|
||||
"tag": "Тег добавлен в импортированные документы",
|
||||
"test": "Проверить параметры",
|
||||
"last_sync": "Последняя синхронизация: {{data.date | date}}, {{data.count}} импортировано",
|
||||
|
@ -369,6 +369,7 @@
|
||||
"port": "IMAP端口(143或993)",
|
||||
"username": "IMAP用户名",
|
||||
"password": "IMAP密码",
|
||||
"folder": "IMAP 件夹中",
|
||||
"tag": "标签添加到导入的文档",
|
||||
"test": "测试参数",
|
||||
"last_sync": "上次同步:{{ data.date | date }},{{ data.count }}消息导入",
|
||||
|
@ -369,6 +369,7 @@
|
||||
"port": "IMAP端口(143或993)",
|
||||
"username": "IMAP用戶名",
|
||||
"password": "IMAP密碼",
|
||||
"folder": "IMAP 資料夾",
|
||||
"tag": "標籤添加到導入的文檔",
|
||||
"test": "測試參數",
|
||||
"last_sync": "上次同步:{{ data.date | date }},{{data.count}}消息導入",
|
||||
|
@ -59,6 +59,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="inboxFolder">{{ 'settings.inbox.folder' | translate }}</label>
|
||||
<div class="col-sm-7">
|
||||
<input name="folder" type="text" class="form-control" id="inboxFolder" ng-model="inbox.folder" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="inboxTag">{{ 'settings.inbox.tag' | translate }}</label>
|
||||
<div class="col-sm-7">
|
||||
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=26
|
||||
db.version=27
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=26
|
||||
db.version=27
|
@ -243,6 +243,7 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(993, json.getJsonNumber("port").intValue());
|
||||
Assert.assertEquals("", json.getString("username"));
|
||||
Assert.assertEquals("", json.getString("password"));
|
||||
Assert.assertEquals("INBOX", json.getString("folder"));
|
||||
Assert.assertEquals("", json.getString("tag"));
|
||||
JsonObject lastSync = json.getJsonObject("last_sync");
|
||||
Assert.assertTrue(lastSync.isNull("date"));
|
||||
@ -260,6 +261,7 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
.param("port", "9755")
|
||||
.param("username", "test@sismics.com")
|
||||
.param("password", "12345678")
|
||||
.param("folder", "INBOX")
|
||||
.param("tag", tagInboxId)
|
||||
), JsonObject.class);
|
||||
|
||||
@ -272,6 +274,7 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(9755, json.getInt("port"));
|
||||
Assert.assertEquals("test@sismics.com", json.getString("username"));
|
||||
Assert.assertEquals("12345678", json.getString("password"));
|
||||
Assert.assertEquals("INBOX", json.getString("folder"));
|
||||
Assert.assertEquals(tagInboxId, json.getString("tag"));
|
||||
|
||||
ServerSetup serverSetupSmtp = new ServerSetup(9754, null, ServerSetup.PROTOCOL_SMTP);
|
||||
|
Loading…
Reference in New Issue
Block a user