'init'
This commit is contained in:
23
app/providers/InformationProvider/useUserCacheFunc.ts
Normal file
23
app/providers/InformationProvider/useUserCacheFunc.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useDatabase } from "@/app/providers/DatabaseProvider/useDatabase";
|
||||
import { UserInformation } from "./InformationProvider";
|
||||
import { OnlineState } from "../ProtocolProvider/protocol/packets/packet.onlinestate";
|
||||
|
||||
export function useUserCacheFunc() {
|
||||
const {getQuery} = useDatabase();
|
||||
|
||||
const getUserInformation = async (publicKey: string): Promise<UserInformation | null> => {
|
||||
const result = await getQuery("SELECT * FROM `cached_users` WHERE `public_key` = ?", [publicKey]);
|
||||
if(!result){
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
publicKey: result.public_key,
|
||||
verified: result.verified,
|
||||
title: result.title,
|
||||
username: result.username,
|
||||
online: OnlineState.OFFLINE
|
||||
};
|
||||
}
|
||||
|
||||
return getUserInformation;
|
||||
}
|
||||
Reference in New Issue
Block a user