2021-01-22 19:41:11 +02:00
|
|
|
import BaseModel from '../BaseModel';
|
|
|
|
import { MasterKeyEntity } from '../services/database/types';
|
|
|
|
import BaseItem from './BaseItem';
|
2017-12-12 20:41:02 +02:00
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
export default class MasterKey extends BaseItem {
|
2017-12-12 20:41:02 +02:00
|
|
|
static tableName() {
|
|
|
|
return 'master_keys';
|
|
|
|
}
|
|
|
|
|
|
|
|
static modelType() {
|
|
|
|
return BaseModel.TYPE_MASTER_KEY;
|
|
|
|
}
|
|
|
|
|
2017-12-13 20:57:40 +02:00
|
|
|
static encryptionSupported() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-14 21:39:13 +02:00
|
|
|
static latest() {
|
|
|
|
return this.modelSelectOne('SELECT * FROM master_keys WHERE created_time >= (SELECT max(created_time) FROM master_keys)');
|
|
|
|
}
|
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
static allWithoutEncryptionMethod(masterKeys: MasterKeyEntity[], method: number) {
|
2020-05-21 10:14:33 +02:00
|
|
|
return masterKeys.filter(m => m.encryption_method !== method);
|
2020-03-13 19:42:50 +02:00
|
|
|
}
|
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
static async save(o: MasterKeyEntity, options: any = null) {
|
2020-05-21 10:14:33 +02:00
|
|
|
return super.save(o, options).then(item => {
|
2017-12-14 21:39:13 +02:00
|
|
|
this.dispatch({
|
|
|
|
type: 'MASTERKEY_UPDATE_ONE',
|
|
|
|
item: item,
|
|
|
|
});
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
}
|
2017-12-12 20:41:02 +02:00
|
|
|
}
|