Merged with Maix Master
This commit is contained in:
parent
ea023fa99a
commit
266feb22f4
9 changed files with 52 additions and 45 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"socket.io-client": "^4.8.1",
|
"socket.io-client": "^4.8.2",
|
||||||
"tailwindcss": "^4.1.18"
|
"tailwindcss": "^4.1.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
frontend/pnpm-lock.yaml
generated
12
frontend/pnpm-lock.yaml
generated
|
|
@ -21,8 +21,8 @@ importers:
|
||||||
specifier: ^1.5.4
|
specifier: ^1.5.4
|
||||||
version: 1.5.4
|
version: 1.5.4
|
||||||
socket.io-client:
|
socket.io-client:
|
||||||
specifier: ^4.8.1
|
specifier: ^4.8.2
|
||||||
version: 4.8.1
|
version: 4.8.2
|
||||||
tailwindcss:
|
tailwindcss:
|
||||||
specifier: ^4.1.18
|
specifier: ^4.1.18
|
||||||
version: 4.1.18
|
version: 4.1.18
|
||||||
|
|
@ -675,8 +675,8 @@ packages:
|
||||||
set-blocking@2.0.0:
|
set-blocking@2.0.0:
|
||||||
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
||||||
|
|
||||||
socket.io-client@4.8.1:
|
socket.io-client@4.8.2:
|
||||||
resolution: {integrity: sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ==}
|
resolution: {integrity: sha512-4MY14EMsyEPFA6lM01XIYepRdV8P6dUir2hxAlAysOYcbNAy5QNHYgIHOcQ1KYM7wTcKnKEW/ZRoIxRinWRXvA==}
|
||||||
engines: {node: '>=10.0.0'}
|
engines: {node: '>=10.0.0'}
|
||||||
|
|
||||||
socket.io-parser@4.2.4:
|
socket.io-parser@4.2.4:
|
||||||
|
|
@ -1286,10 +1286,10 @@ snapshots:
|
||||||
|
|
||||||
set-blocking@2.0.0: {}
|
set-blocking@2.0.0: {}
|
||||||
|
|
||||||
socket.io-client@4.8.1:
|
socket.io-client@4.8.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@socket.io/component-emitter': 3.1.2
|
'@socket.io/component-emitter': 3.1.2
|
||||||
debug: 4.3.7
|
debug: 4.4.3
|
||||||
engine.io-client: 6.6.3
|
engine.io-client: 6.6.3
|
||||||
socket.io-parser: 4.2.4
|
socket.io-parser: 4.2.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
"@fastify/websocket": "^11.2.0",
|
"@fastify/websocket": "^11.2.0",
|
||||||
"fastify": "^5.6.2",
|
"fastify": "^5.6.2",
|
||||||
"fastify-plugin": "^5.1.0",
|
"fastify-plugin": "^5.1.0",
|
||||||
"socket.io": "^4.8.1",
|
"socket.io": "^4.8.2",
|
||||||
"typebox": "^1.0.65"
|
"typebox": "^1.0.65"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,11 @@
|
||||||
import type { ClientMessage } from './chat_types';
|
import type { ClientMessage, BlockRelation} from './chat_types';
|
||||||
import { clientChat } from './app';
|
import { clientChat } from './app';
|
||||||
import { FastifyInstance } from 'fastify';
|
import { FastifyInstance } from 'fastify';
|
||||||
import { getUserByName } from './getUserByName';
|
import { getUserByName } from './getUserByName';
|
||||||
import type { User } from '@shared/database/mixin/user';
|
import type { User } from '@shared/database/mixin/user';
|
||||||
import { color } from './app';
|
import { color } from './app';
|
||||||
|
import { checkNamePair } from './checkNamePair';
|
||||||
type BlockRelation = {
|
import { whoBlockedMe } from './whoBlockedMe';
|
||||||
blocked: string;
|
|
||||||
blocker: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkNamePair(list: BlockRelation[], name1: string, name2: string): (boolean) {
|
|
||||||
const matches: BlockRelation[] = [];
|
|
||||||
let exists: boolean = false;
|
|
||||||
for (const item of list) {
|
|
||||||
if (item.blocker === name1) {
|
|
||||||
matches.push(item);
|
|
||||||
if (item.blocked === name2) {
|
|
||||||
exists = true;
|
|
||||||
return true;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exists;
|
|
||||||
}
|
|
||||||
|
|
||||||
function whoBlockedMe(fastify: FastifyInstance, myID: string): BlockRelation [] {
|
|
||||||
const usersBlocked =
|
|
||||||
fastify.db.getAllBlockedUsers() ?? [];
|
|
||||||
|
|
||||||
return usersBlocked
|
|
||||||
.filter(entry => entry.blocked === myID)
|
|
||||||
.map(entry => ({
|
|
||||||
blocked: entry.user,
|
|
||||||
blocker: entry.blocked,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) {
|
export async function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,3 +48,8 @@ export type obj =
|
||||||
SenderWindowID: string,
|
SenderWindowID: string,
|
||||||
Sendertext: string,
|
Sendertext: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type BlockRelation = {
|
||||||
|
blocked: string;
|
||||||
|
blocker: string;
|
||||||
|
};
|
||||||
16
src/chat/src/checkNamePair.ts
Normal file
16
src/chat/src/checkNamePair.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { BlockRelation} from './chat_types';
|
||||||
|
|
||||||
|
export function checkNamePair(list: BlockRelation[], name1: string, name2: string): (boolean) {
|
||||||
|
const matches: BlockRelation[] = [];
|
||||||
|
let exists: boolean = false;
|
||||||
|
for (const item of list) {
|
||||||
|
if (item.blocker === name1) {
|
||||||
|
matches.push(item);
|
||||||
|
if (item.blocked === name2) {
|
||||||
|
exists = true;
|
||||||
|
return true;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
16
src/chat/src/whoBlockedMe.ts
Normal file
16
src/chat/src/whoBlockedMe.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { FastifyInstance } from 'fastify';
|
||||||
|
import type { BlockRelation} from './chat_types';
|
||||||
|
|
||||||
|
export function whoBlockedMe(fastify: FastifyInstance, myID: string): BlockRelation [] {
|
||||||
|
const usersBlocked =
|
||||||
|
fastify.db.getAllBlockedUsers() ?? [];
|
||||||
|
|
||||||
|
return usersBlocked
|
||||||
|
.filter(entry => entry.blocked === myID)
|
||||||
|
.map(entry => ({
|
||||||
|
blocked: entry.user,
|
||||||
|
blocker: entry.blocked,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,13 +23,13 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
||||||
"@typescript-eslint/parser": "^8.50.0",
|
"@typescript-eslint/parser": "^8.50.1",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^16.2.7",
|
"lint-staged": "^16.2.7",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.50.0",
|
"typescript-eslint": "^8.50.1",
|
||||||
"vite": "^7.3.0"
|
"vite": "^7.3.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"@fastify/websocket": "^11.2.0",
|
"@fastify/websocket": "^11.2.0",
|
||||||
"fastify": "^5.6.2",
|
"fastify": "^5.6.2",
|
||||||
"fastify-plugin": "^5.1.0",
|
"fastify-plugin": "^5.1.0",
|
||||||
"socket.io": "^4.8.1",
|
"socket.io": "^4.8.2",
|
||||||
"typebox": "^1.0.65"
|
"typebox": "^1.0.65"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue