Compare commits
2 Commits
65b5a3c29c
...
860334a86b
| Author | SHA1 | Date | |
|---|---|---|---|
| 860334a86b | |||
| 944d731573 |
@@ -0,0 +1,25 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: Middleware
|
||||||
|
metadata:
|
||||||
|
name: lms-api-strip
|
||||||
|
spec:
|
||||||
|
stripPrefix:
|
||||||
|
prefixes:
|
||||||
|
- /lms-api
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: lms-api
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- web
|
||||||
|
routes:
|
||||||
|
- match: Host(`workspace.autonomystudio.net`) && PathPrefix(`/lms-api`)
|
||||||
|
kind: Rule
|
||||||
|
middlewares:
|
||||||
|
- name: lms-api-strip
|
||||||
|
services:
|
||||||
|
- name: lms-be
|
||||||
|
port: 4400
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ const AI_CHAT_CONTEXT_MESSAGE_LIMIT = 6;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ChatService {
|
export class ChatService {
|
||||||
private readonly authServerUrl: string;
|
private readonly authServerUrl: string;
|
||||||
|
private readonly authPublicUrl: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly authService: AuthService,
|
private readonly authService: AuthService,
|
||||||
@@ -71,6 +72,9 @@ export class ChatService {
|
|||||||
this.authServerUrl = this.configService
|
this.authServerUrl = this.configService
|
||||||
.get<string>('AUTH_SERVER_URL', 'http://localhost:4100')
|
.get<string>('AUTH_SERVER_URL', 'http://localhost:4100')
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
this.authPublicUrl = this.configService
|
||||||
|
.get<string>('AUTH_PUBLIC_URL', this.authServerUrl)
|
||||||
|
.replace(/\/$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
async listThreads(accessToken: string | undefined, query: ListChatThreadsDto) {
|
async listThreads(accessToken: string | undefined, query: ListChatThreadsDto) {
|
||||||
@@ -977,11 +981,11 @@ export class ChatService {
|
|||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
if (user.authUserId) {
|
if (user.authUserId) {
|
||||||
return `${this.authServerUrl}/auth/users/${user.authUserId}/avatar`;
|
return `${this.authPublicUrl}/auth/users/${user.authUserId}/avatar`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.email) {
|
if (user.email) {
|
||||||
return `${this.authServerUrl}/auth/users/avatar?email=${encodeURIComponent(user.email)}`;
|
return `${this.authPublicUrl}/auth/users/avatar?email=${encodeURIComponent(user.email)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1551,7 +1551,6 @@ export class InstructorService {
|
|||||||
key: storedFileName,
|
key: storedFileName,
|
||||||
body: file.buffer,
|
body: file.buffer,
|
||||||
contentType: file.mimetype,
|
contentType: file.mimetype,
|
||||||
fileName: originalFileName,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await mkdir(COURSE_REFERENCE_UPLOAD_ROOT, { recursive: true });
|
await mkdir(COURSE_REFERENCE_UPLOAD_ROOT, { recursive: true });
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ type UploadPublicFileInput = {
|
|||||||
key: string;
|
key: string;
|
||||||
body: Buffer;
|
body: Buffer;
|
||||||
contentType?: string | null;
|
contentType?: string | null;
|
||||||
fileName?: string | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -53,7 +52,6 @@ export class R2PublicFileService {
|
|||||||
Body: input.body,
|
Body: input.body,
|
||||||
ContentLength: input.body.length,
|
ContentLength: input.body.length,
|
||||||
ContentType: input.contentType ?? 'application/octet-stream',
|
ContentType: input.contentType ?? 'application/octet-stream',
|
||||||
ContentDisposition: input.fileName ? contentDispositionForFile(input.fileName) : undefined,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return this.publicUrl(input.key);
|
return this.publicUrl(input.key);
|
||||||
@@ -120,8 +118,3 @@ export class R2PublicFileService {
|
|||||||
function encodeObjectKey(key: string) {
|
function encodeObjectKey(key: string) {
|
||||||
return key.split('/').map(encodeURIComponent).join('/');
|
return key.split('/').map(encodeURIComponent).join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
function contentDispositionForFile(fileName: string) {
|
|
||||||
const fallbackName = fileName.replace(/[\\\"\r\n]/g, '_');
|
|
||||||
return `attachment; filename="${fallbackName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user