fix
This commit is contained in:
parent
9752259b6f
commit
60f38c778c
|
|
@ -1,7 +1,7 @@
|
||||||
import { validate } from "uuid";
|
import { validate } from "uuid";
|
||||||
import { SAction } from "../actions";
|
import { SAction } from "../actions";
|
||||||
import { SyncConnection } from "../type";
|
|
||||||
import { actstore, broadcastActivity } from "../entity/actstore";
|
import { actstore, broadcastActivity } from "../entity/actstore";
|
||||||
|
import { SyncConnection } from "../type";
|
||||||
|
|
||||||
export const activity: SAction["activity"] = async function (
|
export const activity: SAction["activity"] = async function (
|
||||||
this: SyncConnection,
|
this: SyncConnection,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export const syncHandler: WebSocketHandler<WSData> = {
|
||||||
const client_id = createId();
|
const client_id = createId();
|
||||||
conns.set(client_id, {
|
conns.set(client_id, {
|
||||||
user_id: "",
|
user_id: "",
|
||||||
|
user: null,
|
||||||
client_id,
|
client_id,
|
||||||
ws,
|
ws,
|
||||||
msg: { pending: {}, resolve: {} },
|
msg: { pending: {}, resolve: {} },
|
||||||
|
|
@ -58,7 +59,9 @@ export const syncHandler: WebSocketHandler<WSData> = {
|
||||||
const msg = packr.unpack(Buffer.from(raw));
|
const msg = packr.unpack(Buffer.from(raw));
|
||||||
if (msg.type === SyncType.UserID) {
|
if (msg.type === SyncType.UserID) {
|
||||||
const { user_id, page_id, site_id } = msg;
|
const { user_id, page_id, site_id } = msg;
|
||||||
|
|
||||||
conn.user_id = user_id;
|
conn.user_id = user_id;
|
||||||
|
conn.user = await db.user.findFirst({ where: { id: user_id } });
|
||||||
|
|
||||||
let conf = await user.conf.getOrCreate(user_id);
|
let conf = await user.conf.getOrCreate(user_id);
|
||||||
if (site_id) {
|
if (site_id) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { ServerWebSocket } from "bun";
|
import { ServerWebSocket } from "bun";
|
||||||
import { UserConf } from "./entity/user";
|
import { UserConf } from "./entity/user";
|
||||||
import { WSData } from "../../../../pkgs/core/server/create";
|
import { WSData } from "../../../../pkgs/core/server/create";
|
||||||
|
import { user } from "../../../db/db";
|
||||||
|
|
||||||
export enum SyncType {
|
export enum SyncType {
|
||||||
ClientID,
|
ClientID,
|
||||||
|
|
@ -12,6 +13,7 @@ export enum SyncType {
|
||||||
|
|
||||||
export type SyncConnection = {
|
export type SyncConnection = {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
user: null | user;
|
||||||
client_id: string;
|
client_id: string;
|
||||||
conf?: UserConf & { toJSON: () => UserConf };
|
conf?: UserConf & { toJSON: () => UserConf };
|
||||||
ws: ServerWebSocket<WSData>;
|
ws: ServerWebSocket<WSData>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue