Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class ConnectionController {
@UseGuards(AuthGuard('jwt'))
async getConnection(@Query() queryDto: ConnectionQueryDto, @User() user: UserDto) {
const { type, id } = queryDto;

console.log('type:', type);
console.log('id:', id);
switch (type) {
case 'connection':
return await this.connectionService.getConnection(id as string, user.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export class ConnectionService {

async createGuestConnection() {
const connectionId = uuidv4();
await this.GeneralRedis.hset(connectionId, { type: 'guest' });
await Promise.all([
this.GeneralRedis.hset(connectionId, { type: 'guest', aiCount: 0, title: '제목없음' }),
this.GeneralRedis.set(`mindmapState:${connectionId}`, JSON.stringify({})),
this.GeneralRedis.set(`content:${connectionId}`, ''),
]);
return { connectionId, role: 'owner' };
}

Expand All @@ -39,7 +43,8 @@ export class ConnectionService {

async setConnection(mindmapId: number, userId: number) {
const role = await this.userService.getRole(userId, mindmapId);
if (!role) {
this.logger.log(`role: ${role}`);
if (role === undefined) {
throw new ForbiddenException('권한이 없습니다.');
}

Expand Down
8 changes: 6 additions & 2 deletions BE/apps/api-server/src/modules/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, UseGuards } from '@nestjs/common';
import { Controller, Get, UnauthorizedException, UseGuards } from '@nestjs/common';
import { UserService } from './user.service';
import { AuthGuard } from '@nestjs/passport';
import { User } from '../../decorators';
Expand All @@ -10,6 +10,10 @@ export class UserController {
@Get('info')
@UseGuards(AuthGuard('jwt'))
async getUserInfo(@User() user) {
return await this.userService.getUserInfo(user.id);
try {
return await this.userService.getUserInfo(user.id);
} catch {
throw new UnauthorizedException();
}
}
}
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="ko">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
Expand Down
2 changes: 2 additions & 0 deletions client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ instance.interceptors.response.use(
originalRequest.headers["Authorization"] = `Bearer ${newAccessToken.accessToken}`;
return instance(originalRequest);
} catch (error) {
await signOut();
useConnectionStore.getState().logout();
return Promise.reject(error);
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/konva_mindmap/utils/nodeAttrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const TEXT_WIDTH = (depth: number) => NODE_DEFAULT_SIZE * 2 - depth * 18;

//CONNECTED_LINE
export const CONNECTED_LINE_FROM = (depth: number) => NODE_DEFAULT_SIZE - depth * 7 + 10;
export const CONNECTED_LINE_TO = (depth: number) => NODE_DEFAULT_SIZE - depth * 7 + 5;
export const CONNECTED_LINE_TO = (depth: number) => NODE_DEFAULT_SIZE - depth * 7 + 3;

//TEXT
export const TEXT_FONT_SIZE = 16;
Expand Down
1 change: 1 addition & 0 deletions client/src/store/createAuthSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const createAuthSlice: StateCreator<ConnectionStore, [], [], AuthSlice> =
logout: () => {
set({ email: null, name: null, token: "" });
get().resetOwnedMindMap();
location.href = "/";
},

setUser: (email: string, name: string, id: number) => {
Expand Down
1 change: 1 addition & 0 deletions client/src/store/createSharedSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const createSharedSlice: StateCreator<ConnectionStore, [], [], SharedSlic
get().token
? get().addOwnedMindMap(newMindMapConnectionId)
: get().addOwnedMindMapForGuest(newMindMapConnectionId);
get().connectSocket(newMindMapConnectionId);
navigate(`/mindmap/${newMindMapConnectionId}?mode=${targetMode}`);
} catch (error) {
throw error;
Expand Down
1 change: 0 additions & 1 deletion client/src/store/createSocketSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export const createSocketSlice: StateCreator<ConnectionStore, [], [], SocketSlic
if (socket) socket.disconnect();
const response = await createMindmap();
const connectionId = response.data.connectionId;
get().connectSocket(connectionId);
return connectionId;
} catch (error) {
throw error;
Expand Down
7 changes: 6 additions & 1 deletion client/src/utils/formData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export function audioFormData(file: File, mindmapId: string, connectionId: string) {
const formData = new FormData();
formData.append("aiAudio", file);

const encodedFileName = encodeURIComponent(file.name);
const encodedFile = new File([file], encodedFileName, { type: file.type });

formData.append("aiAudio", encodedFile);
formData.append("mindmapId", mindmapId);
formData.append("connectionId", connectionId);

return formData;
}
Loading