-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
376 additions
and
10 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/backend/src/prisma/migrations/20240522182248_add_legal_columns/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- RedefineTables | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_settings" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"rateLimitWindow" INTEGER NOT NULL, | ||
"rateLimitMax" INTEGER NOT NULL, | ||
"secret" TEXT NOT NULL, | ||
"serviceName" TEXT NOT NULL, | ||
"chunkSize" TEXT NOT NULL, | ||
"chunkedUploadsTimeout" INTEGER NOT NULL, | ||
"maxSize" TEXT NOT NULL, | ||
"generateZips" BOOLEAN NOT NULL, | ||
"generateOriginalFileNameWithIdentifier" BOOLEAN NOT NULL DEFAULT false, | ||
"generatedFilenameLength" INTEGER NOT NULL, | ||
"generatedAlbumLength" INTEGER NOT NULL, | ||
"generatedLinksLength" INTEGER NOT NULL DEFAULT 8, | ||
"blockedExtensions" TEXT NOT NULL, | ||
"blockNoExtension" BOOLEAN NOT NULL, | ||
"publicMode" BOOLEAN NOT NULL, | ||
"userAccounts" BOOLEAN NOT NULL, | ||
"disableStatisticsCron" BOOLEAN NOT NULL, | ||
"disableUpdateCheck" BOOLEAN NOT NULL DEFAULT false, | ||
"backgroundImageURL" TEXT NOT NULL, | ||
"logoURL" TEXT NOT NULL, | ||
"metaDescription" TEXT NOT NULL, | ||
"metaKeywords" TEXT NOT NULL, | ||
"metaTwitterHandle" TEXT NOT NULL, | ||
"metaDomain" TEXT NOT NULL DEFAULT '', | ||
"serveUploadsFrom" TEXT NOT NULL DEFAULT '', | ||
"enableMixedCaseFilenames" BOOLEAN NOT NULL DEFAULT true, | ||
"usersStorageQuota" TEXT NOT NULL DEFAULT '0', | ||
"useNetworkStorage" BOOLEAN NOT NULL DEFAULT false, | ||
"useMinimalHomepage" BOOLEAN NOT NULL DEFAULT false, | ||
"useUrlShortener" BOOLEAN NOT NULL DEFAULT false, | ||
"generateThumbnails" BOOLEAN NOT NULL DEFAULT true, | ||
"privacyPolicyPageContent" TEXT NOT NULL DEFAULT '', | ||
"termsOfServicePageContent" TEXT NOT NULL DEFAULT '', | ||
"rulesPageContent" TEXT NOT NULL DEFAULT '', | ||
"S3Region" TEXT NOT NULL DEFAULT '', | ||
"S3Bucket" TEXT NOT NULL DEFAULT '', | ||
"S3AccessKey" TEXT NOT NULL DEFAULT '', | ||
"S3SecretKey" TEXT NOT NULL DEFAULT '', | ||
"S3Endpoint" TEXT NOT NULL DEFAULT '', | ||
"S3PublicUrl" TEXT NOT NULL DEFAULT '' | ||
); | ||
INSERT INTO "new_settings" ("S3AccessKey", "S3Bucket", "S3Endpoint", "S3PublicUrl", "S3Region", "S3SecretKey", "backgroundImageURL", "blockNoExtension", "blockedExtensions", "chunkSize", "chunkedUploadsTimeout", "disableStatisticsCron", "disableUpdateCheck", "enableMixedCaseFilenames", "generateOriginalFileNameWithIdentifier", "generateThumbnails", "generateZips", "generatedAlbumLength", "generatedFilenameLength", "generatedLinksLength", "id", "logoURL", "maxSize", "metaDescription", "metaDomain", "metaKeywords", "metaTwitterHandle", "publicMode", "rateLimitMax", "rateLimitWindow", "secret", "serveUploadsFrom", "serviceName", "useMinimalHomepage", "useNetworkStorage", "useUrlShortener", "userAccounts", "usersStorageQuota") SELECT "S3AccessKey", "S3Bucket", "S3Endpoint", "S3PublicUrl", "S3Region", "S3SecretKey", "backgroundImageURL", "blockNoExtension", "blockedExtensions", "chunkSize", "chunkedUploadsTimeout", "disableStatisticsCron", "disableUpdateCheck", "enableMixedCaseFilenames", "generateOriginalFileNameWithIdentifier", "generateThumbnails", "generateZips", "generatedAlbumLength", "generatedFilenameLength", "generatedLinksLength", "id", "logoURL", "maxSize", "metaDescription", "metaDomain", "metaKeywords", "metaTwitterHandle", "publicMode", "rateLimitMax", "rateLimitWindow", "secret", "serveUploadsFrom", "serviceName", "useMinimalHomepage", "useNetworkStorage", "useUrlShortener", "userAccounts", "usersStorageQuota" FROM "settings"; | ||
DROP TABLE "settings"; | ||
ALTER TABLE "new_settings" RENAME TO "settings"; | ||
PRAGMA foreign_key_check; | ||
PRAGMA foreign_keys=ON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { FastifyReply } from 'fastify'; | ||
import { z } from 'zod'; | ||
import type { RequestWithUser } from '@/structures/interfaces.js'; | ||
import { SETTINGS } from '@/structures/settings.js'; | ||
|
||
const publicSettings = [ | ||
'serviceName', | ||
'metaDescription', | ||
'metaKeywords', | ||
'metaTwitterHandle', | ||
'metaDomain', | ||
'chunkSize', | ||
'maxSize', | ||
'logoURL', | ||
'backgroundImageURL', | ||
'publicMode', | ||
'userAccounts', | ||
'blockedExtensions', | ||
'useNetworkStorage', | ||
'useMinimalHomepage', | ||
'serveUploadsFrom', | ||
'useUrlShortener', | ||
'privacyPolicyPageContent', | ||
'termsOfServicePageContent', | ||
'rulesPageContent' | ||
]; | ||
|
||
export const schema = { | ||
summary: 'Get setting', | ||
describe: 'Get the current value of a specific setting of the instance', | ||
tags: ['Server'], | ||
response: { | ||
200: z.object({ | ||
value: z.any().optional().describe('The value of the requested setting key.') | ||
}) | ||
} | ||
}; | ||
|
||
export const options = { | ||
url: '/settings/:key', | ||
method: 'get', | ||
middlewares: [ | ||
{ | ||
name: 'auth', | ||
optional: true | ||
}, | ||
{ | ||
name: 'apiKey', | ||
optional: true | ||
} | ||
] | ||
}; | ||
|
||
export const run = (req: RequestWithUser, res: FastifyReply) => { | ||
const { key } = req.params as { key: string }; | ||
|
||
if (publicSettings.includes(key)) { | ||
return res.send({ value: SETTINGS[key] }); | ||
} | ||
|
||
if (!req.user) return res.status(403).send({ message: 'Forbidden' }); | ||
|
||
if (!req.user.roles.some(role => role.name === 'admin' || role.name === 'owner')) | ||
return res.status(403).send({ message: 'Forbidden' }); | ||
|
||
if (!SETTINGS[key]) return res.status(404).send({ message: 'Setting not found' }); | ||
return res.send({ value: SETTINGS[key] }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions
46
packages/next/src/app/(home)/(legal)/privacy-policy/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { CustomMDX } from '@/components/mdx/Mdx'; | ||
import request from '@/lib/request'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
export function generateMetadata() { | ||
const section = 'Privacy policy'; | ||
return { | ||
title: section, | ||
description: section, | ||
openGraph: { | ||
title: section, | ||
description: section, | ||
type: 'article', | ||
images: ['/og'] | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
title: section, | ||
description: section, | ||
images: ['/og'] | ||
} | ||
}; | ||
} | ||
|
||
export default async function PrivacyPolicy() { | ||
const { data } = await request.get({ | ||
url: `settings/privacyPolicyPageContent`, | ||
options: { | ||
next: { | ||
tags: ['settings'] | ||
} | ||
} | ||
}); | ||
|
||
if (!data) { | ||
return notFound(); | ||
} | ||
|
||
return ( | ||
<section> | ||
<article className="prose"> | ||
<CustomMDX source={data.value} /> | ||
</article> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { CustomMDX } from '@/components/mdx/Mdx'; | ||
import request from '@/lib/request'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
export function generateMetadata() { | ||
const section = 'Rules'; | ||
return { | ||
title: section, | ||
description: section, | ||
openGraph: { | ||
title: section, | ||
description: section, | ||
type: 'article', | ||
images: ['/og'] | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
title: section, | ||
description: section, | ||
images: ['/og'] | ||
} | ||
}; | ||
} | ||
|
||
export default async function Rules() { | ||
const { data } = await request.get({ | ||
url: `settings/rulesPageContent`, | ||
options: { | ||
next: { | ||
tags: ['settings'] | ||
} | ||
} | ||
}); | ||
|
||
if (!data) { | ||
return notFound(); | ||
} | ||
|
||
return ( | ||
<section> | ||
<article className="prose"> | ||
<CustomMDX source={data.value} /> | ||
</article> | ||
</section> | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/next/src/app/(home)/(legal)/terms-of-service/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { CustomMDX } from '@/components/mdx/Mdx'; | ||
import request from '@/lib/request'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
export function generateMetadata() { | ||
const section = 'Terms of service'; | ||
return { | ||
title: section, | ||
description: section, | ||
openGraph: { | ||
title: section, | ||
description: section, | ||
type: 'article', | ||
images: ['/og'] | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
title: section, | ||
description: section, | ||
images: ['/og'] | ||
} | ||
}; | ||
} | ||
|
||
export default async function TermsOfService() { | ||
const { data } = await request.get({ | ||
url: `settings/termsOfServicePageContent`, | ||
options: { | ||
next: { | ||
tags: ['settings'] | ||
} | ||
} | ||
}); | ||
|
||
if (!data) { | ||
return notFound(); | ||
} | ||
|
||
return ( | ||
<section> | ||
<article className="prose"> | ||
<CustomMDX source={data.value} /> | ||
</article> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.