Skip to content

Commit

Permalink
Merge branch 'BC-8403-code-improvments' of github.com:hpi-schul-cloud…
Browse files Browse the repository at this point in the history
…/tldraw-server into BC-8403-code-improvments
  • Loading branch information
bischofmax committed Dec 12, 2024
2 parents 715b14e + 5664f91 commit 3e98e71
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/infra/y-redis/testing/y-redis-user.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ export const yRedisUserFactory = Factory.define<YRedisUser>(({ sequence }) => {
awarenessLastClock: 0,
awarenessLastUpdated: new Date(),
isClosed: false,
hasError: (): boolean => error !== null,
};
});
11 changes: 0 additions & 11 deletions src/infra/y-redis/y-redis-user.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
let _idCnt = 0;

export class YRedisUser {
public subs: Set<string>;
public id: number;
public awarenessId: number | null;
public awarenessLastClock: number;
public isClosed: boolean;
Expand All @@ -21,16 +18,8 @@ export class YRedisUser {
) {
this.initialRedisSubId = '0';
this.subs = new Set();
/**
* This is just an identifier to keep track of the user for logging purposes.
*/
this.id = _idCnt++; // TODO
this.awarenessId = null;
this.awarenessLastClock = 0;
this.isClosed = false;
}

public hasError(): boolean {
return this.error !== null;
}
}
7 changes: 3 additions & 4 deletions src/infra/y-redis/y-redis.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ export class YRedisClient implements OnModuleInit {
};

public constructor(
private readonly store: DocumentStorage, // TODO: Naming?
private readonly storage: DocumentStorage, // TODO: Naming?
public readonly redis: RedisAdapter,
private readonly logger: Logger,
) {
this.logger.setContext(YRedisClient.name);
this.store = store;
this.redisPrefix = redis.redisPrefix;
}

Expand Down Expand Up @@ -68,7 +67,7 @@ export class YRedisClient implements OnModuleInit {
}

public getStateVector(room: string, docid = '/'): Promise<Uint8Array | null> {
return this.store.retrieveStateVector(room, docid);
return this.storage.retrieveStateVector(room, docid);
}

public async getDoc(room: string, docid: string): Promise<YRedisDoc> {
Expand All @@ -81,7 +80,7 @@ export class YRedisClient implements OnModuleInit {
const ms = extractMessagesFromStreamReply(streamReply, this.redisPrefix);

const docMessages = ms.get(room)?.get(docid) ?? null;
const docstate = await this.store.retrieveDoc(room, docid);
const docstate = await this.storage.retrieveDoc(room, docid);

const ydoc = new Doc();
const awareness = new Awareness(ydoc);
Expand Down
3 changes: 1 addition & 2 deletions src/modules/server/api/websocket.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export class WebsocketGateway implements OnModuleInit, OnModuleDestroy {
aborted = true;
});

// TODO: Das throwed nicht ! Was macht das aborted?
const authPayload = await this.authorizationService.hasPermission(req);
if (aborted) return;

Expand All @@ -97,7 +96,7 @@ export class WebsocketGateway implements OnModuleInit, OnModuleDestroy {
res.cork(() => {
res.writeStatus('500 Internal Server Error').end('Internal Server Error');
});
this.logger.warning(error); // TODO: this.logger.error nur das interface erlaubt es gerade nicht
this.logger.warning(error);
}
}

Expand Down

0 comments on commit 3e98e71

Please sign in to comment.