Skip to content

Commit 2f18773

Browse files
authored
feat: allow uploading images for appeals and reports (#1688)
1 parent 993fad4 commit 2f18773

File tree

76 files changed

+5140
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5140
-479
lines changed

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ LOG_LEVEL=info
3434

3535
# Set to 'production' for production builds
3636
NODE_ENV=development
37+
38+
# File upload configuration
39+
# Maximum upload size (supports human-readable formats: 5MB, 10MB, 1GB, etc.)
40+
UPLOAD_MAX_SIZE=10MB
41+
42+
# Path where uploaded documents are stored
43+
UPLOAD_PATH=./uploads/documents
44+
45+
# Maximum image dimension (width or height) in pixels to prevent pixel bombs
46+
UPLOAD_MAX_DIMENSION=8192
47+
48+
# How long before unattached documents are considered orphaned (in hours)
49+
DOCUMENT_CLEANUP_AGE_HOURS=24

.github/workflows/build.yaml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ jobs:
3232
uses: actions/setup-node@v4
3333
with:
3434
node-version: ${{ matrix.node-version }}
35-
- name: Cache Node.js modules
35+
- name: Cache Node.js modules and Next.js build
3636
uses: actions/cache@v4
3737
with:
38-
# npm cache files are stored in `~/.npm` on Linux/macOS
39-
path: ~/.npm
40-
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
38+
path: |
39+
~/.npm
40+
${{ github.workspace }}/.next/cache
41+
# Generate a new cache whenever packages or source files change
42+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
43+
# If source files changed but packages didn't, rebuild from a prior cache
4144
restore-keys: |
42-
${{ runner.OS }}-node-
43-
${{ runner.OS }}-
45+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
4446
- run: npm ci
4547
- name: Set up MySQL
4648
run: |
@@ -54,16 +56,27 @@ jobs:
5456
LOG_LEVEL: warn
5557
PORT: 3001
5658

59+
- name: Setup E2E database
60+
run: node cypress/setup.js
61+
env:
62+
DB_PASSWORD:
63+
DB_NAME: bm_e2e_tests
64+
65+
- name: Build for E2E
66+
run: npm run build
67+
env:
68+
DB_PASSWORD:
69+
DB_NAME: bm_e2e_tests
70+
NODE_ENV: production
71+
5772
- name: Cypress run
58-
uses: cypress-io/github-action@v2
73+
uses: cypress-io/github-action@v6
5974
env:
6075
DB_PASSWORD:
6176
DB_NAME: bm_e2e_tests
6277
LOG_LEVEL: warn
6378
PORT: 3000
6479
NODE_ENV: production
65-
ADMIN_USERNAME: "admin@banmanagement.com"
66-
ADMIN_PASSWORD: "P%@#fjdVJ3Y%pdGR" # Keep this as is to avoid HIBP failing checks
6780
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
6881
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6982
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }}
@@ -72,7 +85,6 @@ jobs:
7285
NOTIFICATION_VAPID_PRIVATE_KEY: ${{ secrets.NOTIFICATION_VAPID_PRIVATE_KEY }}
7386
with:
7487
install: false
75-
build: npm run e2e:build
7688
start: npm start
7789
wait-on: "http://127.0.0.1:3000"
7890
record: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ bundles
1111
.travis/*.key
1212
.travis/*.key.pub
1313
public/images/opengraph/cache
14+
15+
uploads/**/*
16+
!uploads/documents/.gitkeep

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ RUN addgroup --system --gid 1001 nodejs
3636
RUN adduser --system --uid 1001 nextjs
3737

3838
RUN mkdir -p /app/.next/cache/images && chown nextjs:nodejs /app/.next/cache/images
39+
RUN mkdir -p /app/uploads/documents && chown nextjs:nodejs /app/uploads/documents
3940

4041
COPY --from=builder --chown=nextjs:nodejs /app ./
4142

4243
VOLUME /app/.next/cache/images
4344
VOLUME /app/public/images/opengraph/cache
45+
VOLUME /app/uploads/documents
4446

4547
USER nextjs
4648

components/AdminLayout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Link from 'next/link'
33
import { useRouter, withRouter } from 'next/router'
44
import clsx from 'clsx'
55
import { BiServer } from 'react-icons/bi'
6-
import { MdOutlineGroups, MdOutlineExitToApp, MdOutlineNotifications, MdLogout, MdSettings, MdWebhook } from 'react-icons/md'
6+
import { MdOutlineGroups, MdOutlineExitToApp, MdOutlineNotifications, MdLogout, MdSettings, MdWebhook, MdOutlineImage } from 'react-icons/md'
77
import Avatar from './Avatar'
88
import Loader from './Loader'
99
import ErrorLayout from './ErrorLayout'
@@ -12,6 +12,7 @@ import SessionNavProfile from './SessionNavProfile'
1212
import { useApi, useUser } from '../utils'
1313

1414
const icons = {
15+
Documents: <MdOutlineImage />,
1516
Roles: <MdOutlineGroups />,
1617
Servers: <BiServer />,
1718
'Notification Rules': <MdOutlineNotifications />,

0 commit comments

Comments
 (0)