Merged with Maix Master
This commit is contained in:
parent
ea023fa99a
commit
266feb22f4
9 changed files with 52 additions and 45 deletions
|
|
@ -26,7 +26,7 @@
|
|||
"@fastify/websocket": "^11.2.0",
|
||||
"fastify": "^5.6.2",
|
||||
"fastify-plugin": "^5.1.0",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io": "^4.8.2",
|
||||
"typebox": "^1.0.65"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -1,41 +1,11 @@
|
|||
import type { ClientMessage } from './chat_types';
|
||||
import type { ClientMessage, BlockRelation} from './chat_types';
|
||||
import { clientChat } from './app';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import { getUserByName } from './getUserByName';
|
||||
import type { User } from '@shared/database/mixin/user';
|
||||
import { color } from './app';
|
||||
|
||||
type BlockRelation = {
|
||||
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,
|
||||
}));
|
||||
}
|
||||
import { checkNamePair } from './checkNamePair';
|
||||
import { whoBlockedMe } from './whoBlockedMe';
|
||||
|
||||
export async function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) {
|
||||
|
||||
|
|
|
|||
|
|
@ -48,3 +48,8 @@ export type obj =
|
|||
SenderWindowID: 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": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
||||
"@typescript-eslint/parser": "^8.50.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
||||
"@typescript-eslint/parser": "^8.50.1",
|
||||
"eslint": "^9.39.2",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.2.7",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.50.0",
|
||||
"typescript-eslint": "^8.50.1",
|
||||
"vite": "^7.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
"@fastify/websocket": "^11.2.0",
|
||||
"fastify": "^5.6.2",
|
||||
"fastify-plugin": "^5.1.0",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io": "^4.8.2",
|
||||
"typebox": "^1.0.65"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue