Skip to content

Commit 3ca9a39

Browse files
committed
🐛 [Fix]: 썸네일 기본 이미지 설정
1 parent 31ccb9f commit 3ca9a39

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

.github/workflows/media-deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ on:
33
push:
44
branches:
55
- develop
6-
paths:
7-
- 'apps/media/**'
6+
- Fix/326
7+
# paths:
8+
# - 'apps/media/**'
89

910
jobs:
1011
build-and-push:

.github/workflows/record-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- develop
6+
- Fix/326
67
paths:
78
- 'apps/record/**'
89
jobs:

apps/media/src/sfu/sfu.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ConfigService } from '@nestjs/config';
2-
import { Injectable } from '@nestjs/common';
2+
import { Inject, Injectable } from '@nestjs/common';
33
import * as mediasoup from 'mediasoup';
44
import { ConnectTransportDto } from './dto/transport-params.interface';
55
import { RoomService } from './services/room.service';
@@ -15,6 +15,8 @@ import { ClientService } from './services/client.service';
1515
import { RecordService } from './services/record.service';
1616
import { User } from '../types/user';
1717
import { SetVideoQualityDto } from './dto/set-video-quality.dto';
18+
import { IApiClient } from 'src/common/clients/api-client.interface';
19+
// import axios from 'axios';
1820

1921
@Injectable()
2022
export class SfuService {
@@ -27,10 +29,18 @@ export class SfuService {
2729
private readonly recordService: RecordService,
2830
private readonly clientService: ClientService,
2931
private readonly configService: ConfigService,
32+
@Inject('API_CLIENT')
33+
private readonly apiClient: IApiClient,
3034
) {}
3135

3236
async createRoom(clientId: string, user: User) {
3337
const room = await this.roomService.createRoom();
38+
// await axios.post(`${this.configService.get('RECORD_SERVER_URL')}/thumbnail`, {
39+
// roomId: room.id,
40+
// });
41+
42+
this.apiClient.post(`${this.configService.get('RECORD_SERVER_URL')}/thumbnail`, { roomId: room.id });
43+
3444
const thumbnail = `${this.configService.get('PUBLIC_RECORD_SERVER_URL')}/statics/thumbnails/${room.id}.jpg`;
3545
await this.broadcasterService.createBroadcast(
3646
CreateBroadcastDto.of(room.id, `${user.camperId}님의 방송`, thumbnail, user.id),

apps/record/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ WORKDIR /app
1010

1111
RUN mkdir -p /app/assets/records /app/assets/thumbnails && chmod -R 777 /app/assets
1212

13+
COPY ./apps/record/public/default-thumbnail.jpg /app/assets/default-thumbnail.jpg
14+
RUN chmod 644 /app/assets/default-thumbnail.jpg
15+
1316
# Environment variables
1417
ARG RECORD_PORT
1518
ARG NCLOUD_ACCESS_KEY
235 KB
Loading

apps/record/src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const app = express();
1212
const assetsDirPath = path.join(__dirname, '../assets');
1313
const thumbnailsDirPath = path.join(__dirname, '../assets/thumbnails');
1414
const recordsDirPath = path.join(__dirname, '../assets/records');
15+
const defaultThumbnailPath = path.join(__dirname, '../assets/default-thumbnail.jpg');
1516

1617
app.use(express.json());
1718
app.use(cors());
@@ -29,6 +30,17 @@ if (!fs.existsSync(recordsDirPath)) {
2930
fs.mkdirSync(recordsDirPath, { recursive: true });
3031
}
3132

33+
app.post('/thumbnail', (req, res) => {
34+
const { roomId } = req.body;
35+
try {
36+
const newThumbnailPath = path.join(thumbnailsDirPath, `${roomId}.jpg`);
37+
fs.copyFileSync(defaultThumbnailPath, newThumbnailPath);
38+
res.send({ success: true });
39+
} catch (error) {
40+
res.status(500).send({ success: false, error: 'Failed to create thumbnail' });
41+
}
42+
});
43+
3244
app.post('/send', (req, res) => {
3345
const { videoPort, roomId, type, audioPort } = req.body;
3446
createFfmpegProcess(videoPort, assetsDirPath, roomId, type, audioPort);

0 commit comments

Comments
 (0)