fix: fix archive body encryption trying to encode/decode the archive as JSON

This commit is contained in:
Dragory 2021-10-09 14:51:18 +03:00
parent ba4c54c41b
commit ea95f3af18
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -11,8 +11,8 @@ import {
guildToTemplateSafeGuild,
userToTemplateSafeUser,
} from "../utils/templateSafeObjects";
import { decryptJson, encryptJson } from "../utils/cryptHelpers";
import { SavedMessage } from "./entities/SavedMessage";
import { decrypt, encrypt } from "../utils/crypt";
const DEFAULT_EXPIRY_DAYS = 30;
@ -35,13 +35,13 @@ export class GuildArchives extends BaseGuildRepository<ArchiveEntry> {
return entity;
}
entity.body = await decryptJson(entity.body as unknown as string);
entity.body = await decrypt(entity.body);
return entity;
}
protected async _processEntityToDB(entity: Partial<ArchiveEntry>) {
if (entity.body) {
entity.body = (await encryptJson(entity.body)) as any;
entity.body = await encrypt(entity.body);
}
return entity;
}