|
16 | 16 | use OCP\AppFramework\Http\NotFoundResponse; |
17 | 17 | use OCP\AppFramework\Http\Response; |
18 | 18 | use OCP\AppFramework\Middleware; |
| 19 | +use OCP\Files\NotFoundException; |
| 20 | +use OCP\Files\SimpleFS\ISimpleFile; |
19 | 21 | use OCP\IConfig; |
20 | 22 | use OCP\IGroupManager; |
21 | 23 | use OCP\IRequest; |
@@ -61,25 +63,14 @@ private function getImageFromDomain(Response $response, string $type): Response |
61 | 63 | return $response; |
62 | 64 | } |
63 | 65 |
|
64 | | - if ($type === 'logo') { |
65 | | - $file = $this->companyService->getThemeFile('core/img/logo.png'); |
66 | | - $mime = 'image/png'; |
67 | | - } elseif ($type === 'favicon') { |
68 | | - $file = $this->companyService->getThemeFile('core/img/favicon.png'); |
69 | | - $mime = 'image/png'; |
70 | | - } elseif ($type === 'background') { |
71 | | - $file = $this->companyService->getThemeFile('core/img/background.png'); |
72 | | - $mime = 'image/png'; |
73 | | - } else { |
74 | | - return new NotFoundResponse(); |
75 | | - } |
| 66 | + $file = $this->companyService->getThemeFile('core/img/' . $type); |
76 | 67 |
|
77 | 68 | if ($response instanceof NotFoundResponse) { |
78 | 69 | $response = new FileDisplayResponse($file); |
79 | 70 | $csp = new ContentSecurityPolicy(); |
80 | 71 | $csp->allowInlineStyle(); |
81 | 72 | $response->cacheFor(3600); |
82 | | - $response->addHeader('Content-Type', $mime); |
| 73 | + $response->addHeader('Content-Type', $file->getMimeType()); |
83 | 74 | $response->addHeader('Content-Disposition', 'attachment; filename="' . $type . '"'); |
84 | 75 | $response->setContentSecurityPolicy($csp); |
85 | 76 | } else { |
|
0 commit comments