mirror of https://github.com/Nofated095/Q2TG.git
perf: 使用 Bytes 存放 md5
This commit is contained in:
parent
1727c39603
commit
c44e1be231
|
@ -83,5 +83,5 @@ model AvatarCache {
|
|||
id Int @id @default(autoincrement())
|
||||
forwardPair ForwardPair @relation(fields: [forwardPairId], references: [id])
|
||||
forwardPairId Int @unique
|
||||
hash String
|
||||
hash Bytes
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import db from '../providers/db';
|
|||
import { Api, utils } from 'telegram';
|
||||
import commands from '../constants/commands';
|
||||
import OicqClient from '../client/OicqClient';
|
||||
import { md5B64 } from '../utils/hashing';
|
||||
import { md5 } from '../utils/hashing';
|
||||
import TelegramChat from '../client/TelegramChat';
|
||||
import forwardPairs from '../providers/forwardPairs';
|
||||
|
||||
|
@ -174,7 +174,7 @@ export default class ConfigService {
|
|||
// 更新头像
|
||||
status && await status.edit({ text: '正在更新头像…' });
|
||||
const avatar = await getAvatar(roomId);
|
||||
const avatarHash = md5B64(avatar);
|
||||
const avatarHash = md5(avatar);
|
||||
await chatForBot.setProfilePhoto(avatar);
|
||||
await db.avatarCache.create({
|
||||
data: { forwardPairId: dbPair.id, hash: avatarHash },
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import crypto from 'crypto';
|
||||
|
||||
export function md5(input: crypto.BinaryLike) {
|
||||
const hash = crypto.createHash('md5');
|
||||
return hash.update(input).digest();
|
||||
}
|
||||
|
||||
export function md5Hex(input: crypto.BinaryLike) {
|
||||
const hash = crypto.createHash('md5');
|
||||
return hash.update(input).digest('hex');
|
||||
|
|
Loading…
Reference in New Issue