snappymail/dev/Remote/User/Fetch.js

80 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-02-24 06:11:12 +08:00
import { pString, pInt, b64EncodeJSONSafe } from 'Common/Utils';
2016-06-30 08:02:45 +08:00
import {
2022-02-24 06:11:12 +08:00
getFolderFromCacheList
} from 'Common/Cache';
2016-06-30 08:02:45 +08:00
2021-03-10 18:44:48 +08:00
import { SettingsGet } from 'Common/Globals';
2021-01-27 19:02:37 +08:00
import { SUB_QUERY_PREFIX } from 'Common/Links';
2016-06-30 08:02:45 +08:00
import { AppUserStore } from 'Stores/User/App';
import { SettingsUserStore } from 'Stores/User/Settings';
2016-06-30 08:02:45 +08:00
import { AbstractFetchRemote } from 'Remote/AbstractFetch';
class RemoteUserFetch extends AbstractFetchRemote {
2016-06-30 08:02:45 +08:00
/**
* @param {?Function} fCallback
2021-11-30 17:19:43 +08:00
* @param {string} sFolderFullName
* @param {number} iUid
* @returns {boolean}
*/
2021-11-30 17:19:43 +08:00
message(fCallback, sFolderFullName, iUid) {
sFolderFullName = pString(sFolderFullName);
iUid = pInt(iUid);
2021-11-30 17:19:43 +08:00
if (getFolderFromCacheList(sFolderFullName) && 0 < iUid) {
this.abort('Message').request('Message',
2019-07-05 03:19:24 +08:00
fCallback,
{},
null,
'Message/' +
2021-01-27 19:02:37 +08:00
SUB_QUERY_PREFIX +
2019-07-05 03:19:24 +08:00
'/' +
2021-12-07 20:23:38 +08:00
b64EncodeJSONSafe([
2021-11-30 17:19:43 +08:00
sFolderFullName,
iUid,
AppUserStore.threadsAllowed() && SettingsUserStore.useThreads() ? 1 : 0,
SettingsGet('AccountHash')
])
2019-07-05 03:19:24 +08:00
);
return true;
}
return false;
}
/**
* @param {?Function} fCallback
* @param {Object} oData
*/
saveSettings(fCallback, oData) {
this.request('SettingsUpdate', fCallback, oData);
}
/**
* @param {string} key
2021-03-18 23:12:24 +08:00
* @param {?scalar} value
* @param {?Function} fCallback
*/
2021-03-18 23:12:24 +08:00
saveSetting(key, value, fCallback) {
this.saveSettings(fCallback, {
[key]: value
});
}
/*
folderMove(sPrevFolderFullName, sNewFolderFullName, bSubscribe) {
return this.post('FolderMove', FolderUserStore.foldersRenaming, {
2021-11-30 17:19:43 +08:00
Folder: sPrevFolderFullName,
NewFolder: sNewFolderFullName,
Subscribe: bSubscribe ? 1 : 0
});
}
*/
}
2016-06-30 08:02:45 +08:00
export default new RemoteUserFetch();