mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-09-20 06:08:46 +00:00
Can be automatically be notified of comments creation
This commit is contained in:
@@ -15,8 +15,9 @@ import { PostAccessLevel } from "./Post";
|
||||
import { CommentsHelper } from "../helpers/CommentsHelper";
|
||||
import { checkVirtualDirectory } from "../utils/VirtualDirsUtils";
|
||||
import { ConversationsHelper } from "../helpers/ConversationsHelper";
|
||||
import { AbstractUserConnectionContainer } from "./UserConnectionContainer";
|
||||
|
||||
export abstract class BaseRequestsHandler {
|
||||
export abstract class BaseRequestsHandler implements AbstractUserConnectionContainer {
|
||||
|
||||
protected abstract get userID() : number;
|
||||
|
||||
|
29
src/entities/UserConnectionContainer.ts
Normal file
29
src/entities/UserConnectionContainer.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Simple user connection container
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
export abstract class AbstractUserConnectionContainer {
|
||||
public abstract getUserId() : number;
|
||||
public abstract get signedIn() : boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fake user connnection checker used for notifications in WebSockets
|
||||
*/
|
||||
export class AbritraryUserConnection implements AbstractUserConnectionContainer {
|
||||
|
||||
constructor(private userID: number) {}
|
||||
|
||||
public getUserId(): number {
|
||||
if(!this.signedIn)
|
||||
throw new Error("User is not signed in!");
|
||||
|
||||
return this.userID;
|
||||
}
|
||||
public get signedIn(): boolean {
|
||||
return this.userID > 0;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user