merge: pull latest from upstream fluxerapp/fluxer
Some checks failed
deploy admin / channel-vars (push) Successful in 18s
deploy api / channel-vars (push) Successful in 4s
deploy app / channel-vars (push) Successful in 3s
deploy docs / channel-vars (push) Successful in 3s
deploy marketing / channel-vars (push) Successful in 4s
deploy api / Deploy api (push) Has been cancelled
deploy app / Deploy app (push) Has been cancelled
deploy media-proxy / Deploy media proxy (push) Has been cancelled
deploy docs / Deploy docs (push) Has been cancelled
deploy metrics / Deploy metrics (push) Has been cancelled
deploy static-proxy / Deploy static proxy (push) Has been cancelled
deploy admin / Deploy admin (push) Has been cancelled
deploy marketing / Deploy marketing (push) Has been cancelled
Some checks failed
deploy admin / channel-vars (push) Successful in 18s
deploy api / channel-vars (push) Successful in 4s
deploy app / channel-vars (push) Successful in 3s
deploy docs / channel-vars (push) Successful in 3s
deploy marketing / channel-vars (push) Successful in 4s
deploy api / Deploy api (push) Has been cancelled
deploy app / Deploy app (push) Has been cancelled
deploy media-proxy / Deploy media proxy (push) Has been cancelled
deploy docs / Deploy docs (push) Has been cancelled
deploy metrics / Deploy metrics (push) Has been cancelled
deploy static-proxy / Deploy static proxy (push) Has been cancelled
deploy admin / Deploy admin (push) Has been cancelled
deploy marketing / Deploy marketing (push) Has been cancelled
# Conflicts: # .dockerignore # .gitattributes # .gitignore # README.md # dev/Caddyfile.dev # dev/compose.yaml # fluxer_api/src/rate_limit_configs/AuthRateLimitConfig.ts # fluxer_app/rspack.config.mjs
This commit is contained in:
@@ -1,4 +1,54 @@
|
||||
Dockerfile
|
||||
target
|
||||
.mongo
|
||||
.env
|
||||
# Generated artifacts and caches
|
||||
**/_build
|
||||
**/_checkouts
|
||||
**/_vendor
|
||||
**/build
|
||||
**/coverage
|
||||
**/dist
|
||||
**/generated
|
||||
**/.cache
|
||||
**/.pnpm-store
|
||||
**/target
|
||||
**/certificates
|
||||
**/node_modules
|
||||
|
||||
# Tooling & editor metadata
|
||||
**/.idea
|
||||
**/.vscode
|
||||
**/.DS_Store
|
||||
**/Thumbs.db
|
||||
**/.git
|
||||
**/.astro/
|
||||
**/.env
|
||||
**/.env.local
|
||||
**/.env.*.local
|
||||
**/.dev.vars
|
||||
|
||||
# Logs & temporary files
|
||||
**/*.dump
|
||||
**/*.lock
|
||||
**/*.log
|
||||
**/*.tmp
|
||||
**/*.swo
|
||||
**/*.swp
|
||||
**/*~
|
||||
**/log
|
||||
**/logs
|
||||
**/npm-debug.log*
|
||||
**/pnpm-debug.log*
|
||||
**/yarn-debug.log*
|
||||
**/yarn-error.log*
|
||||
**/rebar3.crashdump
|
||||
**/erl_crash.dump
|
||||
|
||||
# Runtime config
|
||||
dev
|
||||
**/.rebar
|
||||
**/.rebar3
|
||||
|
||||
/fluxer_app/src/data/emojis.json
|
||||
/fluxer_app/src/locales/*/messages.js
|
||||
!fluxer_app/dist
|
||||
!fluxer_app/dist/**
|
||||
!fluxer_devops/cassandra/migrations
|
||||
!scripts/cassandra-migrate/Cargo.lock
|
||||
|
||||
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 120
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
[*.{yml,yaml,Dockerfile}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[justfile]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
36
.gitattributes
vendored
36
.gitattributes
vendored
@@ -1,34 +1,2 @@
|
||||
# Auto-detect text files and normalize line endings to LF
|
||||
* text=auto eol=lf
|
||||
|
||||
# Explicitly declare text files
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.py text eol=lf
|
||||
*.conf text eol=lf
|
||||
*.cfg text eol=lf
|
||||
*.ini text eol=lf
|
||||
*.toml text eol=lf
|
||||
*.env text eol=lf
|
||||
*.html text eol=lf
|
||||
*.css text eol=lf
|
||||
*.js text eol=lf
|
||||
*.xml text eol=lf
|
||||
*.sql text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
.gitignore text eol=lf
|
||||
.gitattributes text eol=lf
|
||||
|
||||
# Binary files
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.pem binary
|
||||
*.ppk binary
|
||||
*.asc binary
|
||||
* text=auto
|
||||
fluxer_static/** filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
custom: ['https://fluxer.app/donate']
|
||||
100
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
100
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
name: Bug report
|
||||
description: Report a reproducible problem in fluxer
|
||||
title: 'bug: '
|
||||
labels: ['bug']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for the report!
|
||||
|
||||
**Security note:** Please do not report security issues here. Use https://fluxer.app/security instead.
|
||||
|
||||
Before filing, please check for existing issues and include enough detail for someone else to reproduce.
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: Summary
|
||||
description: What happened, in one or two sentences?
|
||||
placeholder: 'When I ..., the app ..., but I expected ...'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Provide clear, numbered steps. Include any relevant data/inputs.
|
||||
placeholder: |
|
||||
1. Go to ...
|
||||
2. Click ...
|
||||
3. See error ...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
placeholder: 'It should ...'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual behavior
|
||||
placeholder: 'Instead, it ...'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Where does this bug appear?
|
||||
options:
|
||||
- Backend / API
|
||||
- Frontend / Web
|
||||
- Mobile
|
||||
- CLI / tooling
|
||||
- CI / build
|
||||
- Docs
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: Environment
|
||||
description: Include versions that matter (commit SHA/tag, OS, runtime, browser/device).
|
||||
placeholder: |
|
||||
- Commit/Tag:
|
||||
- OS:
|
||||
- Runtime (node/go/python/etc):
|
||||
- Browser (if applicable):
|
||||
- Deployment (local/dev/prod):
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs / screenshots
|
||||
description: Paste logs (redact secrets) and/or attach screenshots/recordings.
|
||||
placeholder: 'Paste stack traces, console output, network errors, etc.'
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Pre-flight checks
|
||||
options:
|
||||
- label: I searched for existing issues and didn't find a duplicate.
|
||||
required: true
|
||||
- label: This is not a security vulnerability report (those go to https://fluxer.app/security).
|
||||
required: true
|
||||
- label: I included enough information to reproduce the issue.
|
||||
required: true
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Security vulnerability report
|
||||
url: https://fluxer.app/security
|
||||
about: Please report security issues privately using our security policy.
|
||||
45
.github/ISSUE_TEMPLATE/docs.yml
vendored
Normal file
45
.github/ISSUE_TEMPLATE/docs.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Documentation
|
||||
description: Report a docs issue or suggest an improvement
|
||||
title: 'docs: '
|
||||
labels: ['docs']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks! Clear docs save everyone time.
|
||||
|
||||
**Security note:** Please do not report security issues here. Use https://fluxer.app/security instead.
|
||||
- type: textarea
|
||||
id: issue
|
||||
attributes:
|
||||
label: What's wrong or missing?
|
||||
description: Describe the docs gap, error, ambiguity, or outdated info.
|
||||
placeholder: 'The README says ..., but actually ...'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: location
|
||||
attributes:
|
||||
label: Where is it?
|
||||
description: Link the file/section if possible.
|
||||
placeholder: "File: ...\nSection/heading: ...\nLink: ..."
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: suggestion
|
||||
attributes:
|
||||
label: Suggested improvement (optional)
|
||||
description: If you already know how it should read, propose wording.
|
||||
placeholder: 'Proposed text: ...'
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Pre-flight checks
|
||||
options:
|
||||
- label: I searched for existing issues and didn't find a duplicate.
|
||||
required: true
|
||||
82
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
82
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
name: Feature request
|
||||
description: Suggest an improvement or new capability
|
||||
title: 'feat: '
|
||||
labels: ['enhancement']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to propose an improvement.
|
||||
|
||||
If this is **larger work** (new feature, meaningful refactor, new dependency, new API surface, behavior change),
|
||||
it's best to align with maintainers early; an issue like this is a great place to do that.
|
||||
|
||||
**Security note:** Please do not report security issues here. Use https://fluxer.app/security instead.
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem / motivation
|
||||
description: What problem are you trying to solve? Who is it for?
|
||||
placeholder: "Right now, users can't ..., which causes ..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: What would you like to see happen? Include UX/API shape if relevant.
|
||||
placeholder: 'Add ..., so that ...'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: Other approaches you considered, and why they're worse.
|
||||
placeholder: "- Option A: ...\n- Option B: ..."
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: dropdown
|
||||
id: impact
|
||||
attributes:
|
||||
label: Impact
|
||||
description: Roughly how big is this change?
|
||||
options:
|
||||
- Small (localized, low risk)
|
||||
- Medium (touches multiple areas)
|
||||
- Large (new surface area / refactor / dependency)
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: compatibility
|
||||
attributes:
|
||||
label: Compatibility
|
||||
options:
|
||||
- label: This might be a breaking change (behavior/API).
|
||||
required: false
|
||||
- label: This introduces a new dependency.
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: scope
|
||||
attributes:
|
||||
label: Scope / implementation notes
|
||||
description: Constraints, rough plan, or links to relevant code.
|
||||
placeholder: "Notes: ...\nPotential files/areas: ..."
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
id: contribution
|
||||
attributes:
|
||||
label: Contribution
|
||||
options:
|
||||
- label: I'm willing to open a PR for this (after maintainer alignment).
|
||||
required: false
|
||||
- label: I can help test/verify a PR for this.
|
||||
required: false
|
||||
35
.github/pull_request_template.md
vendored
Normal file
35
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
## Summary
|
||||
|
||||
<!-- A few bullets is perfect: what changed, why it changed, and anything reviewers should pay attention to. -->
|
||||
|
||||
- **What:**
|
||||
- **Why:**
|
||||
- **Notes for reviewers:**
|
||||
|
||||
## How to verify
|
||||
|
||||
<!-- Concrete steps to validate the change. Include screenshots/recordings for UI changes when helpful. -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Tests
|
||||
|
||||
<!-- List what you ran, or explain why tests weren’t added/changed. -->
|
||||
|
||||
- [ ] Added/updated tests (where it makes sense)
|
||||
- [ ] Unit tests:
|
||||
- [ ] Integration tests:
|
||||
- [ ] Manual verification:
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] PR targets `canary`
|
||||
- [ ] PR title follows Conventional Commits (mostly lowercase)
|
||||
- [ ] CI is green (or I’m actively addressing failures)
|
||||
- [ ] CLA signed (the bot will guide you on first PR)
|
||||
|
||||
## Screenshots / recordings (UI changes)
|
||||
|
||||
<!-- Drag and drop images/videos here. -->
|
||||
665
.github/workflows/build-desktop.yaml
vendored
Normal file
665
.github/workflows/build-desktop.yaml
vendored
Normal file
@@ -0,0 +1,665 @@
|
||||
name: build desktop
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
description: Channel to build (stable or canary)
|
||||
required: false
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
ref:
|
||||
description: Git ref to build (branch, tag, or commit SHA)
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
skip_windows:
|
||||
description: Skip Windows builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_macos:
|
||||
description: Skip macOS builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_linux:
|
||||
description: Skip Linux builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_windows_x64:
|
||||
description: Skip Windows x64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_windows_arm64:
|
||||
description: Skip Windows ARM64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_macos_x64:
|
||||
description: Skip macOS x64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_macos_arm64:
|
||||
description: Skip macOS ARM64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_linux_x64:
|
||||
description: Skip Linux x64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
skip_linux_arm64:
|
||||
description: Skip Linux ARM64 builds
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: desktop-${{ inputs.channel }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CHANNEL: ${{ inputs.channel }}
|
||||
BUILD_CHANNEL: ${{ inputs.channel == 'canary' && 'canary' || 'stable' }}
|
||||
SOURCE_REF: ${{ inputs.ref && inputs.ref || (inputs.channel == 'canary' && 'canary' || 'main') }}
|
||||
|
||||
jobs:
|
||||
meta:
|
||||
name: Resolve build metadata
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
outputs:
|
||||
version: ${{ steps.meta.outputs.version }}
|
||||
pub_date: ${{ steps.meta.outputs.pub_date }}
|
||||
channel: ${{ steps.meta.outputs.channel }}
|
||||
build_channel: ${{ steps.meta.outputs.build_channel }}
|
||||
source_ref: ${{ steps.meta.outputs.source_ref }}
|
||||
steps:
|
||||
- name: Set metadata
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="0.0.${GITHUB_RUN_NUMBER}"
|
||||
PUB_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "pub_date=${PUB_DATE}" >> "$GITHUB_OUTPUT"
|
||||
echo "channel=${{ inputs.channel }}" >> "$GITHUB_OUTPUT"
|
||||
echo "build_channel=${{ inputs.channel == 'canary' && 'canary' || 'stable' }}" >> "$GITHUB_OUTPUT"
|
||||
echo "source_ref=${{ (inputs.ref && inputs.ref) || (inputs.channel == 'canary' && 'canary' || 'main') }}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
matrix:
|
||||
name: Resolve build matrix
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Build platform matrix
|
||||
id: set-matrix
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
PLATFORMS='[
|
||||
{"platform":"windows","arch":"x64","os":"windows-latest","electron_arch":"x64"},
|
||||
{"platform":"windows","arch":"arm64","os":"windows-11-arm","electron_arch":"arm64"},
|
||||
{"platform":"macos","arch":"x64","os":"macos-15-intel","electron_arch":"x64"},
|
||||
{"platform":"macos","arch":"arm64","os":"macos-15","electron_arch":"arm64"},
|
||||
{"platform":"linux","arch":"x64","os":"ubuntu-24.04","electron_arch":"x64"},
|
||||
{"platform":"linux","arch":"arm64","os":"ubuntu-24.04-arm","electron_arch":"arm64"}
|
||||
]'
|
||||
|
||||
FILTERED="$(echo "$PLATFORMS" | jq -c \
|
||||
--argjson skipWin '${{ inputs.skip_windows }}' \
|
||||
--argjson skipWinX64 '${{ inputs.skip_windows_x64 }}' \
|
||||
--argjson skipWinArm '${{ inputs.skip_windows_arm64 }}' \
|
||||
--argjson skipMac '${{ inputs.skip_macos }}' \
|
||||
--argjson skipMacX64 '${{ inputs.skip_macos_x64 }}' \
|
||||
--argjson skipMacArm '${{ inputs.skip_macos_arm64 }}' \
|
||||
--argjson skipLinux '${{ inputs.skip_linux }}' \
|
||||
--argjson skipLinuxX64 '${{ inputs.skip_linux_x64 }}' \
|
||||
--argjson skipLinuxArm '${{ inputs.skip_linux_arm64 }}' '
|
||||
[.[] | select(
|
||||
(
|
||||
((.platform == "windows") and (
|
||||
$skipWin or
|
||||
((.arch == "x64") and $skipWinX64) or
|
||||
((.arch == "arm64") and $skipWinArm)
|
||||
)) or
|
||||
((.platform == "macos") and (
|
||||
$skipMac or
|
||||
((.arch == "x64") and $skipMacX64) or
|
||||
((.arch == "arm64") and $skipMacArm)
|
||||
)) or
|
||||
((.platform == "linux") and (
|
||||
$skipLinux or
|
||||
((.arch == "x64") and $skipLinuxX64) or
|
||||
((.arch == "arm64") and $skipLinuxArm)
|
||||
))
|
||||
) | not
|
||||
)]
|
||||
')"
|
||||
|
||||
echo "matrix={\"include\":$FILTERED}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.platform }} (${{ matrix.arch }})
|
||||
needs:
|
||||
- meta
|
||||
- matrix
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
||||
env:
|
||||
APP_WORKDIR: fluxer_app
|
||||
CHANNEL: ${{ needs.meta.outputs.channel }}
|
||||
BUILD_CHANNEL: ${{ needs.meta.outputs.build_channel }}
|
||||
SOURCE_REF: ${{ needs.meta.outputs.source_ref }}
|
||||
VERSION: ${{ needs.meta.outputs.version }}
|
||||
PUB_DATE: ${{ needs.meta.outputs.pub_date }}
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
|
||||
- name: Shorten Windows paths (workspace + temp for Squirrel) and pin pnpm store
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
subst W: "$env:GITHUB_WORKSPACE"
|
||||
"APP_WORKDIR=W:\fluxer_app" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
New-Item -ItemType Directory -Force "C:\t" | Out-Null
|
||||
New-Item -ItemType Directory -Force "C:\sq" | Out-Null
|
||||
New-Item -ItemType Directory -Force "C:\ebcache" | Out-Null
|
||||
"TEMP=C:\t" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
"TMP=C:\t" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
"SQUIRREL_TEMP=C:\sq" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
"ELECTRON_BUILDER_CACHE=C:\ebcache" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
New-Item -ItemType Directory -Force "C:\pnpm-store" | Out-Null
|
||||
"NPM_CONFIG_STORE_DIR=C:\pnpm-store" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
"npm_config_store_dir=C:\pnpm-store" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
|
||||
"store-dir=C:\pnpm-store" | Set-Content -Path "W:\.npmrc" -Encoding ascii
|
||||
git config --global core.longpaths true
|
||||
|
||||
- name: Set up pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.26.0
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Resolve pnpm store path (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$store = pnpm store path --silent
|
||||
"PNPM_STORE_PATH=$store" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
New-Item -ItemType Directory -Force $store | Out-Null
|
||||
|
||||
- name: Resolve pnpm store path (Unix)
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
store="$(pnpm store path --silent)"
|
||||
echo "PNPM_STORE_PATH=$store" >> "$GITHUB_ENV"
|
||||
mkdir -p "$store"
|
||||
|
||||
- name: Cache pnpm store
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.PNPM_STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install Python setuptools (Windows ARM64)
|
||||
if: matrix.platform == 'windows' && matrix.arch == 'arm64'
|
||||
shell: pwsh
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install "setuptools>=69" wheel
|
||||
|
||||
- name: Install Python setuptools (macOS)
|
||||
if: matrix.platform == 'macos'
|
||||
run: brew install python-setuptools
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.platform == 'linux'
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libx11-dev libxtst-dev libxt-dev libxinerama-dev libxkbcommon-dev libxrandr-dev \
|
||||
ruby ruby-dev build-essential rpm \
|
||||
libpixman-1-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
|
||||
sudo gem install --no-document fpm
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Update version
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
run: pnpm version "${{ env.VERSION }}" --no-git-tag-version --allow-same-version
|
||||
|
||||
- name: Build Electron main process
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
env:
|
||||
BUILD_CHANNEL: ${{ env.BUILD_CHANNEL }}
|
||||
run: pnpm electron:compile
|
||||
|
||||
- name: Build Electron app (macOS)
|
||||
if: matrix.platform == 'macos'
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
env:
|
||||
BUILD_CHANNEL: ${{ env.BUILD_CHANNEL }}
|
||||
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
run: pnpm exec electron-builder --config electron-builder.config.cjs --mac --${{ matrix.electron_arch }}
|
||||
|
||||
- name: Verify macOS bundle ID (fail fast if wrong channel)
|
||||
if: matrix.platform == 'macos'
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
shell: bash
|
||||
env:
|
||||
BUILD_CHANNEL: ${{ env.BUILD_CHANNEL }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
DIST="dist-electron"
|
||||
ZIP="$(ls -1 "$DIST"/*"${{ matrix.electron_arch }}"*.zip | head -n1)"
|
||||
tmp="$(mktemp -d)"
|
||||
ditto -xk "$ZIP" "$tmp"
|
||||
APP="$(find "$tmp" -maxdepth 2 -name "*.app" -print -quit)"
|
||||
BID=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$APP/Contents/Info.plist")
|
||||
|
||||
expected="app.fluxer"
|
||||
if [[ "${BUILD_CHANNEL:-stable}" == "canary" ]]; then expected="app.fluxer.canary"; fi
|
||||
echo "Bundle id in zip: $BID (expected: $expected)"
|
||||
test "$BID" = "$expected"
|
||||
|
||||
- name: Build Electron app (Windows)
|
||||
if: matrix.platform == 'windows'
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
env:
|
||||
BUILD_CHANNEL: ${{ env.BUILD_CHANNEL }}
|
||||
TEMP: C:\t
|
||||
TMP: C:\t
|
||||
SQUIRREL_TEMP: C:\sq
|
||||
ELECTRON_BUILDER_CACHE: C:\ebcache
|
||||
run: pnpm exec electron-builder --config electron-builder.config.cjs --win --${{ matrix.electron_arch }}
|
||||
|
||||
- name: Analyze Squirrel nupkg for long paths
|
||||
if: matrix.platform == 'windows'
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
shell: pwsh
|
||||
env:
|
||||
BUILD_VERSION: ${{ env.VERSION }}
|
||||
MAX_WINDOWS_PATH_LEN: 260
|
||||
PATH_HEADROOM: 10
|
||||
run: |
|
||||
$primaryDir = if ("${{ matrix.arch }}" -eq "arm64") { "dist-electron/squirrel-windows-arm64" } else { "dist-electron/squirrel-windows" }
|
||||
$fallbackDir = if ("${{ matrix.arch }}" -eq "arm64") { "dist-electron/squirrel-windows" } else { "dist-electron/squirrel-windows-arm64" }
|
||||
$dirs = @($primaryDir, $fallbackDir)
|
||||
|
||||
$nupkg = $null
|
||||
foreach ($d in $dirs) {
|
||||
if (Test-Path $d) {
|
||||
$nupkg = Get-ChildItem -Path "$d/*.nupkg" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($nupkg) { break }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $nupkg) {
|
||||
throw "No Squirrel nupkg found in: $($dirs -join ', ')"
|
||||
}
|
||||
|
||||
Write-Host "Analyzing Windows installer $($nupkg.FullName)"
|
||||
$env:NUPKG_PATH = $nupkg.FullName
|
||||
|
||||
$lines = @(
|
||||
'import os'
|
||||
'import zipfile'
|
||||
''
|
||||
'path = os.environ["NUPKG_PATH"]'
|
||||
'build_ver = os.environ["BUILD_VERSION"]'
|
||||
'prefix = os.path.join(os.environ["LOCALAPPDATA"], "fluxer_app", f"app-{build_ver}", "resources", "app.asar.unpacked")'
|
||||
'max_len = int(os.environ.get("MAX_WINDOWS_PATH_LEN", "260"))'
|
||||
'headroom = int(os.environ.get("PATH_HEADROOM", "10"))'
|
||||
'limit = max_len - headroom'
|
||||
''
|
||||
'with zipfile.ZipFile(path) as archive:'
|
||||
' entries = []'
|
||||
' for info in archive.infolist():'
|
||||
' normalized = info.filename.lstrip("/\\\\")'
|
||||
' total_len = len(os.path.join(prefix, normalized)) if normalized else len(prefix)'
|
||||
' entries.append((total_len, info.filename))'
|
||||
''
|
||||
'if not entries:'
|
||||
' raise SystemExit("nupkg archive contains no entries")'
|
||||
''
|
||||
'entries.sort(reverse=True)'
|
||||
'print(f"Assumed install prefix: {prefix} ({len(prefix)} chars). Maximum allowed path length: {limit} (total reserve {max_len}, headroom {headroom}).")'
|
||||
'print("Top 20 longest archived paths (length includes prefix):")'
|
||||
'for length, name in entries[:20]:'
|
||||
' print(f"{length:4d} {name}")'
|
||||
''
|
||||
'longest_len, longest_name = entries[0]'
|
||||
'if longest_len > limit:'
|
||||
' raise SystemExit(f"Longest path {longest_len} for {longest_name} exceeds limit {limit}")'
|
||||
'print(f"Longest archived path {longest_len} is within the limit of {limit}.")'
|
||||
)
|
||||
|
||||
$scriptPath = Join-Path $env:TEMP "nupkg-long-path-check.py"
|
||||
Set-Content -Path $scriptPath -Value $lines -Encoding utf8
|
||||
python $scriptPath
|
||||
|
||||
- name: Build Electron app (Linux)
|
||||
if: matrix.platform == 'linux'
|
||||
working-directory: ${{ env.APP_WORKDIR }}
|
||||
env:
|
||||
BUILD_CHANNEL: ${{ env.BUILD_CHANNEL }}
|
||||
USE_SYSTEM_FPM: true
|
||||
run: pnpm exec electron-builder --config electron-builder.config.cjs --linux --${{ matrix.electron_arch }}
|
||||
|
||||
- name: Prepare artifacts (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force upload_staging | Out-Null
|
||||
|
||||
$dist = Join-Path $env:APP_WORKDIR "dist-electron"
|
||||
$sqDirName = if ("${{ matrix.arch }}" -eq "arm64") { "squirrel-windows-arm64" } else { "squirrel-windows" }
|
||||
$sqFallbackName = if ($sqDirName -eq "squirrel-windows") { "squirrel-windows-arm64" } else { "squirrel-windows" }
|
||||
|
||||
$sq = Join-Path $dist $sqDirName
|
||||
$sqFallback = Join-Path $dist $sqFallbackName
|
||||
|
||||
$picked = $null
|
||||
if (Test-Path $sq) { $picked = $sq }
|
||||
elseif (Test-Path $sqFallback) { $picked = $sqFallback }
|
||||
|
||||
if ($picked) {
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$picked\*.exe" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$picked\*.exe.blockmap" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$picked\RELEASES*" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$picked\*.nupkg" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$picked\*.nupkg.blockmap" "upload_staging\"
|
||||
}
|
||||
|
||||
if (Test-Path $dist) {
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$dist\*.yml" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$dist\*.zip" "upload_staging\"
|
||||
Copy-Item -Force -ErrorAction SilentlyContinue "$dist\*.zip.blockmap" "upload_staging\"
|
||||
}
|
||||
|
||||
if (-not (Get-ChildItem upload_staging -Filter *.exe -ErrorAction SilentlyContinue)) {
|
||||
throw "No installer .exe staged. Squirrel outputs were not copied."
|
||||
}
|
||||
|
||||
Get-ChildItem -Force upload_staging | Format-Table -AutoSize
|
||||
|
||||
- name: Prepare artifacts (Unix)
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p upload_staging
|
||||
DIST="${{ env.APP_WORKDIR }}/dist-electron"
|
||||
|
||||
cp -f "$DIST"/*.dmg upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.zip upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.zip.blockmap upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.yml upload_staging/ 2>/dev/null || true
|
||||
|
||||
cp -f "$DIST"/*.AppImage upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.deb upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.rpm upload_staging/ 2>/dev/null || true
|
||||
cp -f "$DIST"/*.tar.gz upload_staging/ 2>/dev/null || true
|
||||
|
||||
ls -la upload_staging/
|
||||
|
||||
- name: Normalize updater YAML (arm64)
|
||||
if: matrix.arch == 'arm64'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd upload_staging
|
||||
[[ "${{ matrix.platform }}" == "macos" && -f latest-mac.yml && ! -f latest-mac-arm64.yml ]] && mv latest-mac.yml latest-mac-arm64.yml || true
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fluxer-desktop-${{ env.BUILD_CHANNEL }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||
path: |
|
||||
upload_staging/*.exe
|
||||
upload_staging/*.exe.blockmap
|
||||
upload_staging/*.dmg
|
||||
upload_staging/*.zip
|
||||
upload_staging/*.zip.blockmap
|
||||
upload_staging/*.AppImage
|
||||
upload_staging/*.deb
|
||||
upload_staging/*.rpm
|
||||
upload_staging/*.tar.gz
|
||||
upload_staging/*.yml
|
||||
upload_staging/*.nupkg
|
||||
upload_staging/*.nupkg.blockmap
|
||||
upload_staging/RELEASES*
|
||||
retention-days: 30
|
||||
|
||||
upload:
|
||||
name: Upload to S3 (rclone)
|
||||
needs:
|
||||
- meta
|
||||
- build
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
env:
|
||||
CHANNEL: ${{ needs.meta.outputs.build_channel }}
|
||||
DISPLAY_CHANNEL: ${{ needs.meta.outputs.channel }}
|
||||
S3_ENDPOINT: https://s3.us-east-va.io.cloud.ovh.us
|
||||
S3_BUCKET: fluxer-downloads
|
||||
PUBLIC_DL_BASE: https://api.fluxer.app/dl
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
pattern: fluxer-desktop-${{ needs.meta.outputs.build_channel }}-*
|
||||
|
||||
- name: Install rclone
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! command -v rclone >/dev/null 2>&1; then
|
||||
curl -fsSL https://rclone.org/install.sh | sudo bash
|
||||
fi
|
||||
|
||||
- name: Configure rclone (OVH S3)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.config/rclone
|
||||
cat > ~/.config/rclone/rclone.conf <<'RCLONEEOF'
|
||||
[ovh]
|
||||
type = s3
|
||||
provider = Other
|
||||
env_auth = true
|
||||
endpoint = https://s3.us-east-va.io.cloud.ovh.us
|
||||
acl = private
|
||||
RCLONEEOF
|
||||
|
||||
- name: Build S3 payload layout (+ manifest.json)
|
||||
env:
|
||||
VERSION: ${{ needs.meta.outputs.version }}
|
||||
PUB_DATE: ${{ needs.meta.outputs.pub_date }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p s3_payload
|
||||
|
||||
shopt -s nullglob
|
||||
for dir in artifacts/fluxer-desktop-${CHANNEL}-*; do
|
||||
[ -d "$dir" ] || continue
|
||||
|
||||
base="$(basename "$dir")"
|
||||
if [[ "$base" =~ ^fluxer-desktop-[a-z]+-([a-z]+)-([a-z0-9]+)$ ]]; then
|
||||
platform="${BASH_REMATCH[1]}"
|
||||
arch="${BASH_REMATCH[2]}"
|
||||
else
|
||||
echo "Skipping unrecognized artifact dir: $base"
|
||||
continue
|
||||
fi
|
||||
|
||||
case "$platform" in
|
||||
windows) plat="win32" ;;
|
||||
macos) plat="darwin" ;;
|
||||
linux) plat="linux" ;;
|
||||
*)
|
||||
echo "Unknown platform: $platform"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
dest="s3_payload/desktop/${CHANNEL}/${plat}/${arch}"
|
||||
mkdir -p "$dest"
|
||||
cp -av "$dir"/* "$dest/" || true
|
||||
|
||||
if [[ "$plat" == "darwin" ]]; then
|
||||
zip_file=""
|
||||
for z in "$dest"/*.zip; do
|
||||
zip_file="$z"
|
||||
break
|
||||
done
|
||||
|
||||
if [[ -z "$zip_file" ]]; then
|
||||
echo "No .zip found for macOS $arch in $dest (auto-update requires zip artifacts)."
|
||||
else
|
||||
zip_name="$(basename "$zip_file")"
|
||||
url="${PUBLIC_DL_BASE}/desktop/${CHANNEL}/${plat}/${arch}/${zip_name}"
|
||||
|
||||
cat > "$dest/RELEASES.json" <<EOF
|
||||
{
|
||||
"currentRelease": "${VERSION}",
|
||||
"releases": [
|
||||
{
|
||||
"version": "${VERSION}",
|
||||
"updateTo": {
|
||||
"version": "${VERSION}",
|
||||
"pub_date": "${PUB_DATE}",
|
||||
"notes": "",
|
||||
"name": "${VERSION}",
|
||||
"url": "${url}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
cp -f "$dest/RELEASES.json" "$dest/releases.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
setup_file=""
|
||||
dmg_file=""
|
||||
zip_file2=""
|
||||
appimage_file=""
|
||||
deb_file=""
|
||||
rpm_file=""
|
||||
targz_file=""
|
||||
|
||||
if [[ "$plat" == "win32" ]]; then
|
||||
setup_file="$(ls -1 "$dest"/*.exe 2>/dev/null | grep -i 'setup' | head -n1 || true)"
|
||||
if [[ -z "$setup_file" ]]; then
|
||||
setup_file="$(ls -1 "$dest"/*.exe 2>/dev/null | head -n1 || true)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$plat" == "darwin" ]]; then
|
||||
dmg_file="$(ls -1 "$dest"/*.dmg 2>/dev/null | head -n1 || true)"
|
||||
zip_file2="$(ls -1 "$dest"/*.zip 2>/dev/null | head -n1 || true)"
|
||||
fi
|
||||
|
||||
if [[ "$plat" == "linux" ]]; then
|
||||
appimage_file="$(ls -1 "$dest"/*.AppImage 2>/dev/null | head -n1 || true)"
|
||||
deb_file="$(ls -1 "$dest"/*.deb 2>/dev/null | head -n1 || true)"
|
||||
rpm_file="$(ls -1 "$dest"/*.rpm 2>/dev/null | head -n1 || true)"
|
||||
targz_file="$(ls -1 "$dest"/*.tar.gz 2>/dev/null | head -n1 || true)"
|
||||
fi
|
||||
|
||||
jq -n \
|
||||
--arg channel "${CHANNEL}" \
|
||||
--arg platform "${plat}" \
|
||||
--arg arch "${arch}" \
|
||||
--arg version "${VERSION}" \
|
||||
--arg pub_date "${PUB_DATE}" \
|
||||
--arg setup "$(basename "${setup_file:-}")" \
|
||||
--arg dmg "$(basename "${dmg_file:-}")" \
|
||||
--arg zip "$(basename "${zip_file2:-}")" \
|
||||
--arg appimage "$(basename "${appimage_file:-}")" \
|
||||
--arg deb "$(basename "${deb_file:-}")" \
|
||||
--arg rpm "$(basename "${rpm_file:-}")" \
|
||||
--arg tar_gz "$(basename "${targz_file:-}")" \
|
||||
'{
|
||||
channel: $channel,
|
||||
platform: $platform,
|
||||
arch: $arch,
|
||||
version: $version,
|
||||
pub_date: $pub_date,
|
||||
files: {
|
||||
setup: $setup,
|
||||
dmg: $dmg,
|
||||
zip: $zip,
|
||||
appimage: $appimage,
|
||||
deb: $deb,
|
||||
rpm: $rpm,
|
||||
tar_gz: $tar_gz
|
||||
}
|
||||
}' > "$dest/manifest.json"
|
||||
done
|
||||
|
||||
echo "Payload tree:"
|
||||
find s3_payload -maxdepth 6 -type f | sort
|
||||
|
||||
- name: Upload payload to S3
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rclone copy s3_payload/desktop "ovh:${S3_BUCKET}/desktop" \
|
||||
--transfers 32 \
|
||||
--checkers 16 \
|
||||
--fast-list \
|
||||
--s3-upload-concurrency 8 \
|
||||
--s3-chunk-size 16M \
|
||||
-v
|
||||
|
||||
- name: Build summary
|
||||
run: |
|
||||
{
|
||||
echo "## Desktop ${DISPLAY_CHANNEL^} Upload Complete"
|
||||
echo ""
|
||||
echo "**Version:** ${{ needs.meta.outputs.version }}"
|
||||
echo ""
|
||||
echo "**S3 prefix:** desktop/${CHANNEL}/"
|
||||
echo ""
|
||||
echo "**Redirect endpoint shape:** /dl/desktop/${CHANNEL}/{plat}/{arch}/{format}"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
94
.github/workflows/channel-vars.yaml
vendored
Normal file
94
.github/workflows/channel-vars.yaml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
name: channel vars
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
github_event_name:
|
||||
type: string
|
||||
github_ref_name:
|
||||
type: string
|
||||
required: false
|
||||
github_ref:
|
||||
type: string
|
||||
required: false
|
||||
workflow_dispatch_channel:
|
||||
type: string
|
||||
required: false
|
||||
workflow_dispatch_ref:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
channel:
|
||||
description: 'Computed release channel (stable|canary)'
|
||||
value: ${{ jobs.emit.outputs.channel }}
|
||||
is_canary:
|
||||
description: 'Whether this is a canary deploy (true|false)'
|
||||
value: ${{ jobs.emit.outputs.is_canary }}
|
||||
source_ref:
|
||||
description: 'Git ref to check out for the deploy'
|
||||
value: ${{ jobs.emit.outputs.source_ref }}
|
||||
stack_suffix:
|
||||
description: "Suffix for stack/image names ('' or '-canary')"
|
||||
value: ${{ jobs.emit.outputs.stack_suffix }}
|
||||
|
||||
jobs:
|
||||
emit:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
channel: ${{ steps.compute.outputs.channel }}
|
||||
is_canary: ${{ steps.compute.outputs.is_canary }}
|
||||
source_ref: ${{ steps.compute.outputs.source_ref }}
|
||||
stack_suffix: ${{ steps.compute.outputs.stack_suffix }}
|
||||
steps:
|
||||
- name: Determine channel
|
||||
id: compute
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
event_name="${{ inputs.github_event_name }}"
|
||||
ref_name="${{ inputs.github_ref_name || '' }}"
|
||||
ref="${{ inputs.github_ref || '' }}"
|
||||
dispatch_channel="${{ inputs.workflow_dispatch_channel || '' }}"
|
||||
dispatch_ref="${{ inputs.workflow_dispatch_ref || '' }}"
|
||||
|
||||
channel="stable"
|
||||
if [[ "${event_name}" == "push" ]]; then
|
||||
if [[ "${ref_name}" == "canary" ]]; then
|
||||
channel="canary"
|
||||
fi
|
||||
else
|
||||
if [[ "${dispatch_channel}" == "canary" ]]; then
|
||||
channel="canary"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${event_name}" == "push" ]]; then
|
||||
source_ref="${ref:-refs/heads/${ref_name:-main}}"
|
||||
else
|
||||
if [[ -n "${dispatch_ref}" ]]; then
|
||||
source_ref="${dispatch_ref}"
|
||||
else
|
||||
if [[ "${channel}" == "canary" ]]; then
|
||||
source_ref="refs/heads/canary"
|
||||
else
|
||||
source_ref="refs/heads/main"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
stack_suffix=""
|
||||
if [[ "${channel}" == "canary" ]]; then
|
||||
stack_suffix="-canary"
|
||||
fi
|
||||
|
||||
is_canary="false"
|
||||
if [[ "${channel}" == "canary" ]]; then
|
||||
is_canary="true"
|
||||
fi
|
||||
|
||||
printf 'channel=%s\n' "${channel}" >> "$GITHUB_OUTPUT"
|
||||
printf 'is_canary=%s\n' "${is_canary}" >> "$GITHUB_OUTPUT"
|
||||
printf 'source_ref=%s\n' "${source_ref}" >> "$GITHUB_OUTPUT"
|
||||
printf 'stack_suffix=%s\n' "${stack_suffix}" >> "$GITHUB_OUTPUT"
|
||||
207
.github/workflows/deploy-admin.yaml
vendored
Normal file
207
.github/workflows/deploy-admin.yaml
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
name: deploy admin
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_admin/**
|
||||
- .github/workflows/deploy-admin.yaml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
description: Channel to deploy
|
||||
ref:
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
description: Optional git ref to deploy (defaults to main/canary based on channel)
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-admin-${{ github.event_name == 'workflow_dispatch' && inputs.channel || (github.ref_name == 'canary' && 'canary') || 'stable' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
channel-vars:
|
||||
uses: ./.github/workflows/channel-vars.yaml
|
||||
with:
|
||||
github_event_name: ${{ github.event_name }}
|
||||
github_ref_name: ${{ github.ref_name }}
|
||||
github_ref: ${{ github.ref }}
|
||||
workflow_dispatch_channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || '' }}
|
||||
workflow_dispatch_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
|
||||
|
||||
deploy:
|
||||
name: Deploy admin
|
||||
needs: channel-vars
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
IS_CANARY: ${{ needs.channel-vars.outputs.is_canary }}
|
||||
SOURCE_REF: ${{ needs.channel-vars.outputs.source_ref }}
|
||||
STACK_SUFFIX: ${{ needs.channel-vars.outputs.stack_suffix }}
|
||||
STACK: ${{ format('fluxer-admin{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
CACHE_SCOPE: ${{ format('deploy-fluxer-admin{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
CADDY_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'admin.canary.fluxer.app' || 'admin.fluxer.app' }}
|
||||
APP_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://web.canary.fluxer.app' || 'https://web.fluxer.app' }}
|
||||
API_PUBLIC_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://api.canary.fluxer.app' || 'https://api.fluxer.app' }}
|
||||
ADMIN_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://admin.canary.fluxer.app' || 'https://admin.fluxer.app' }}
|
||||
ADMIN_REDIRECT_URI: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://admin.canary.fluxer.app/oauth2_callback' || 'https://admin.fluxer.app/oauth2_callback' }}
|
||||
REPLICAS: ${{ needs.channel-vars.outputs.is_canary == 'true' && 1 || 2 }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set build timestamp
|
||||
run: echo "BUILD_TIMESTAMP=$(date -u +%s)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: fluxer_admin
|
||||
file: fluxer_admin/Dockerfile
|
||||
tags: ${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}
|
||||
build-args: |
|
||||
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
STACK: ${{ env.STACK }}
|
||||
APP_ENDPOINT: ${{ env.APP_ENDPOINT }}
|
||||
API_PUBLIC_ENDPOINT: ${{ env.API_PUBLIC_ENDPOINT }}
|
||||
ADMIN_ENDPOINT: ${{ env.ADMIN_ENDPOINT }}
|
||||
ADMIN_REDIRECT_URI: ${{ env.ADMIN_REDIRECT_URI }}
|
||||
CADDY_DOMAIN: ${{ env.CADDY_DOMAIN }}
|
||||
REPLICAS: ${{ env.REPLICAS }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" \
|
||||
"IMAGE_TAG=${IMAGE_TAG} STACK=${STACK} APP_ENDPOINT=${APP_ENDPOINT} API_PUBLIC_ENDPOINT=${API_PUBLIC_ENDPOINT} ADMIN_ENDPOINT=${ADMIN_ENDPOINT} ADMIN_REDIRECT_URI=${ADMIN_REDIRECT_URI} CADDY_DOMAIN=${CADDY_DOMAIN} REPLICAS=${REPLICAS} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p "/opt/${STACK}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${STACK}"
|
||||
cd "/opt/${STACK}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
x-deploy-base: &deploy_base
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
x-healthcheck: &healthcheck
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
FLUXER_API_PUBLIC_ENDPOINT: ${API_PUBLIC_ENDPOINT}
|
||||
FLUXER_APP_ENDPOINT: ${APP_ENDPOINT}
|
||||
FLUXER_MEDIA_ENDPOINT: https://fluxerusercontent.com
|
||||
FLUXER_CDN_ENDPOINT: https://fluxerstatic.com
|
||||
FLUXER_ADMIN_ENDPOINT: ${ADMIN_ENDPOINT}
|
||||
FLUXER_PATH_ADMIN: /
|
||||
APP_MODE: admin
|
||||
FLUXER_ADMIN_PORT: 8080
|
||||
ADMIN_OAUTH2_REDIRECT_URI: ${ADMIN_REDIRECT_URI}
|
||||
ADMIN_OAUTH2_CLIENT_ID: 1440355698178071552
|
||||
ADMIN_OAUTH2_AUTO_CREATE: "false"
|
||||
FLUXER_METRICS_HOST: fluxer-metrics_app:8080
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: ${REPLICAS}
|
||||
labels:
|
||||
- "caddy=${CADDY_DOMAIN}"
|
||||
- 'caddy.reverse_proxy={{upstreams 8080}}'
|
||||
- 'caddy.header.X-Robots-Tag="noindex, nofollow, nosnippet, noimageindex"'
|
||||
- 'caddy.header.Strict-Transport-Security="max-age=31536000; includeSubDomains; preload"'
|
||||
- 'caddy.header.X-Xss-Protection="1; mode=block"'
|
||||
- 'caddy.header.X-Content-Type-Options=nosniff'
|
||||
- 'caddy.header.Referrer-Policy=strict-origin-when-cross-origin'
|
||||
- 'caddy.header.X-Frame-Options=DENY'
|
||||
networks: [fluxer-shared]
|
||||
healthcheck: *healthcheck
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${STACK}"
|
||||
EOF
|
||||
357
.github/workflows/deploy-api.yaml
vendored
Normal file
357
.github/workflows/deploy-api.yaml
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
name: deploy api
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_api/**
|
||||
- .github/workflows/deploy-api.yaml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
description: Channel to deploy
|
||||
ref:
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
description: Optional git ref to deploy (defaults to main/canary based on channel)
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-api-${{ github.event_name == 'workflow_dispatch' && inputs.channel || (github.ref_name == 'canary' && 'canary') || 'stable' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
channel-vars:
|
||||
uses: ./.github/workflows/channel-vars.yaml
|
||||
with:
|
||||
github_event_name: ${{ github.event_name }}
|
||||
github_ref_name: ${{ github.ref_name }}
|
||||
github_ref: ${{ github.ref }}
|
||||
workflow_dispatch_channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || '' }}
|
||||
workflow_dispatch_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
|
||||
|
||||
deploy:
|
||||
name: Deploy api
|
||||
needs: channel-vars
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
IS_CANARY: ${{ needs.channel-vars.outputs.is_canary }}
|
||||
SOURCE_REF: ${{ needs.channel-vars.outputs.source_ref }}
|
||||
STACK_SUFFIX: ${{ needs.channel-vars.outputs.stack_suffix }}
|
||||
|
||||
STACK: ${{ format('fluxer-api{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
WORKER_STACK: ${{ format('fluxer-api-worker{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
CACHE_SCOPE: ${{ format('deploy-fluxer-api{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
|
||||
API_PUBLIC_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://api.canary.fluxer.app' || 'https://api.fluxer.app' }}
|
||||
API_CLIENT_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://web.canary.fluxer.app/api' || 'https://web.fluxer.app/api' }}
|
||||
APP_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://web.canary.fluxer.app' || 'https://web.fluxer.app' }}
|
||||
|
||||
MARKETING_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://canary.fluxer.app' || 'https://fluxer.app' }}
|
||||
|
||||
ADMIN_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://admin.canary.fluxer.app' || 'https://admin.fluxer.app' }}
|
||||
ADMIN_REDIRECT_URI: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://admin.canary.fluxer.app/oauth2_callback' || 'https://admin.fluxer.app/oauth2_callback' }}
|
||||
|
||||
CADDY_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'api.canary.fluxer.app' || 'api.fluxer.app' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image(s)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: fluxer_api
|
||||
file: fluxer_api/Dockerfile
|
||||
tags: |
|
||||
${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
${{ env.WORKER_STACK }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image(s) and deploy
|
||||
env:
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
IMAGE_TAG_APP: ${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
IMAGE_TAG_WORKER: ${{ env.WORKER_STACK }}:${{ env.DEPLOY_SHA }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
docker pussh "${IMAGE_TAG_APP}" "${SERVER}"
|
||||
|
||||
if [[ "${IS_CANARY}" == "true" ]]; then
|
||||
docker pussh "${IMAGE_TAG_WORKER}" "${SERVER}"
|
||||
fi
|
||||
|
||||
ssh "${SERVER}" \
|
||||
"IMAGE_TAG_APP=${IMAGE_TAG_APP} IMAGE_TAG_WORKER=${IMAGE_TAG_WORKER} STACK=${STACK} WORKER_STACK=${WORKER_STACK} IS_CANARY=${IS_CANARY} APP_ENDPOINT=${APP_ENDPOINT} API_PUBLIC_ENDPOINT=${API_PUBLIC_ENDPOINT} API_CLIENT_ENDPOINT=${API_CLIENT_ENDPOINT} MARKETING_ENDPOINT=${MARKETING_ENDPOINT} ADMIN_ENDPOINT=${ADMIN_ENDPOINT} ADMIN_REDIRECT_URI=${ADMIN_REDIRECT_URI} CADDY_DOMAIN=${CADDY_DOMAIN} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
write_runtime_env() {
|
||||
local dir="$1"
|
||||
cat > "${dir}/runtime.env" << ENVEOF
|
||||
NODE_ENV=production
|
||||
FLUXER_API_PORT=8080
|
||||
SENTRY_DSN=https://bb16e8b823b82d788db49a666b3b4b90@o4510149383094272.ingest.us.sentry.io/4510205804019712
|
||||
|
||||
CASSANDRA_HOSTS=cassandra
|
||||
CASSANDRA_KEYSPACE=fluxer
|
||||
CASSANDRA_LOCAL_DC=dc1
|
||||
|
||||
FLUXER_GATEWAY_RPC_HOST=fluxer-gateway_app
|
||||
FLUXER_GATEWAY_RPC_PORT=8081
|
||||
|
||||
FLUXER_MEDIA_PROXY_HOST=fluxer-media-proxy_app
|
||||
FLUXER_MEDIA_PROXY_PORT=8080
|
||||
|
||||
FLUXER_METRICS_HOST=fluxer-metrics_app:8080
|
||||
|
||||
FLUXER_API_CLIENT_ENDPOINT=${API_CLIENT_ENDPOINT}
|
||||
FLUXER_APP_ENDPOINT=${APP_ENDPOINT}
|
||||
FLUXER_CDN_ENDPOINT=https://fluxerstatic.com
|
||||
FLUXER_MEDIA_ENDPOINT=https://fluxerusercontent.com
|
||||
FLUXER_INVITE_ENDPOINT=https://fluxer.gg
|
||||
FLUXER_GIFT_ENDPOINT=https://fluxer.gift
|
||||
|
||||
AWS_S3_ENDPOINT=https://s3.us-east-va.io.cloud.ovh.us
|
||||
AWS_S3_BUCKET_CDN=fluxer
|
||||
AWS_S3_BUCKET_UPLOADS=fluxer-uploads
|
||||
AWS_S3_BUCKET_REPORTS=fluxer-reports
|
||||
AWS_S3_BUCKET_HARVESTS=fluxer-harvests
|
||||
AWS_S3_BUCKET_DOWNLOADS=fluxer-downloads
|
||||
|
||||
SENDGRID_FROM_EMAIL=noreply@fluxer.app
|
||||
SENDGRID_FROM_NAME=Fluxer
|
||||
SENDGRID_WEBHOOK_PUBLIC_KEY=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoeqQS37o9s8ZcLBJUtT4hghAmI5RqsvcQ0OvsUn3XPfl7GkjxljufyxuL8+m1mCHP2IA1jdYT3kJQoQYXP6ZpQ==
|
||||
|
||||
FLUXER_API_PUBLIC_ENDPOINT=${API_PUBLIC_ENDPOINT}
|
||||
FLUXER_GATEWAY_ENDPOINT=wss://gateway.fluxer.app
|
||||
|
||||
FLUXER_MARKETING_ENDPOINT=${MARKETING_ENDPOINT}
|
||||
FLUXER_PATH_MARKETING=/
|
||||
|
||||
FLUXER_ADMIN_ENDPOINT=${ADMIN_ENDPOINT}
|
||||
FLUXER_PATH_ADMIN=/
|
||||
|
||||
ADMIN_OAUTH2_CLIENT_ID=1440355698178071552
|
||||
ADMIN_OAUTH2_REDIRECT_URI=${ADMIN_REDIRECT_URI}
|
||||
ADMIN_OAUTH2_AUTO_CREATE=false
|
||||
|
||||
PASSKEYS_ENABLED=true
|
||||
PASSKEY_RP_NAME=Fluxer
|
||||
PASSKEY_RP_ID=fluxer.app
|
||||
PASSKEY_ALLOWED_ORIGINS=https://web.fluxer.app,https://web.canary.fluxer.app
|
||||
|
||||
CAPTCHA_ENABLED=true
|
||||
CAPTCHA_PRIMARY_PROVIDER=turnstile
|
||||
HCAPTCHA_SITE_KEY=9cbad400-df84-4e0c-bda6-e65000be78aa
|
||||
TURNSTILE_SITE_KEY=0x4AAAAAAB_lAoDdTWznNHMq
|
||||
|
||||
EMAIL_ENABLED=true
|
||||
SMS_ENABLED=true
|
||||
VOICE_ENABLED=true
|
||||
|
||||
SEARCH_ENABLED=true
|
||||
MEILISEARCH_URL=http://meilisearch:7700
|
||||
|
||||
STRIPE_ENABLED=true
|
||||
STRIPE_PRICE_ID_MONTHLY_USD=price_1SJHZzFPC94Os7FdzBgvz0go
|
||||
STRIPE_PRICE_ID_YEARLY_USD=price_1SJHabFPC94Os7FdhSOWVfcr
|
||||
STRIPE_PRICE_ID_VISIONARY_USD=price_1SJHGTFPC94Os7FdWTyqvJZ8
|
||||
STRIPE_PRICE_ID_MONTHLY_EUR=price_1SJHaFFPC94Os7FdmcrGicXa
|
||||
STRIPE_PRICE_ID_YEARLY_EUR=price_1SJHarFPC94Os7Fddbyzr5I8
|
||||
STRIPE_PRICE_ID_VISIONARY_EUR=price_1SJHGnFPC94Os7FdZn23KkYB
|
||||
STRIPE_PRICE_ID_GIFT_VISIONARY_USD=price_1SKhWqFPC94Os7FdxRmQrg3k
|
||||
STRIPE_PRICE_ID_GIFT_VISIONARY_EUR=price_1SKhXrFPC94Os7FdcepLrJqr
|
||||
STRIPE_PRICE_ID_GIFT_1_MONTH_USD=price_1SJHHKFPC94Os7FdGwUs1EQg
|
||||
STRIPE_PRICE_ID_GIFT_1_YEAR_USD=price_1SJHHrFPC94Os7FdWrQN5tKl
|
||||
STRIPE_PRICE_ID_GIFT_1_MONTH_EUR=price_1SJHHaFPC94Os7FdwwpwhliW
|
||||
STRIPE_PRICE_ID_GIFT_1_YEAR_EUR=price_1SJHI5FPC94Os7Fd3DpLxb0D
|
||||
|
||||
FLUXER_VISIONARIES_GUILD_ID=1428504839258075143
|
||||
FLUXER_OPERATORS_GUILD_ID=1434192442151473226
|
||||
|
||||
CLOUDFLARE_PURGE_ENABLED=true
|
||||
|
||||
CLAMAV_ENABLED=true
|
||||
CLAMAV_HOST=clamav
|
||||
CLAMAV_PORT=3310
|
||||
|
||||
MAXMIND_DB_PATH=/data/GeoLite2-City.mmdb
|
||||
|
||||
VAPID_PUBLIC_KEY=BEIwQxIwfj6m90tLYAR0AU_GJWU4kw8J_zJcHQG55NCUWSyRy-dzMOgvxk8yEDwdVyJZa6xUL4fmwngijq8T2pY
|
||||
ENVEOF
|
||||
}
|
||||
|
||||
deploy_api_stack() {
|
||||
sudo mkdir -p "/opt/${STACK}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${STACK}"
|
||||
cd "/opt/${STACK}"
|
||||
|
||||
write_runtime_env "$(pwd)"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
x-deploy-base: &deploy_base
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
x-healthcheck: &healthcheck
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG_APP}
|
||||
command: ['npm', 'run', 'start']
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
- ./runtime.env
|
||||
volumes:
|
||||
- /opt/geoip/GeoLite2-City.mmdb:/data/GeoLite2-City.mmdb:ro
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: 2
|
||||
labels:
|
||||
- "caddy=${CADDY_DOMAIN}"
|
||||
- 'caddy.reverse_proxy={{upstreams 8080}}'
|
||||
- 'caddy.header.Strict-Transport-Security="max-age=31536000; includeSubDomains; preload"'
|
||||
- 'caddy.header.X-Xss-Protection="1; mode=block"'
|
||||
- 'caddy.header.X-Content-Type-Options=nosniff'
|
||||
- 'caddy.header.Referrer-Policy=strict-origin-when-cross-origin'
|
||||
- 'caddy.header.X-Frame-Options=DENY'
|
||||
- 'caddy.header.Expect-Ct="max-age=86400, report-uri=\\"https://o4510149383094272.ingest.us.sentry.io/api/4510205804019712/security/?sentry_key=bb16e8b823b82d788db49a666b3b4b90\\""'
|
||||
networks: [fluxer-shared]
|
||||
healthcheck: *healthcheck
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${STACK}"
|
||||
}
|
||||
|
||||
deploy_worker_stack_canary_only() {
|
||||
if [[ "${IS_CANARY}" != "true" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
sudo mkdir -p "/opt/${WORKER_STACK}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${WORKER_STACK}"
|
||||
cd "/opt/${WORKER_STACK}"
|
||||
|
||||
write_runtime_env "$(pwd)"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
x-deploy-base: &deploy_base
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
services:
|
||||
worker:
|
||||
image: ${IMAGE_TAG_WORKER}
|
||||
command: ['npm', 'run', 'start:worker']
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
- ./runtime.env
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: 1
|
||||
networks: [fluxer-shared]
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${WORKER_STACK}"
|
||||
}
|
||||
|
||||
deploy_api_stack
|
||||
deploy_worker_stack_canary_only
|
||||
EOF
|
||||
353
.github/workflows/deploy-app.yaml
vendored
Normal file
353
.github/workflows/deploy-app.yaml
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
name: deploy app
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_app/**
|
||||
- .github/workflows/deploy-app.yaml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
description: Channel to deploy
|
||||
ref:
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
description: Optional git ref to deploy (defaults to main/canary based on channel)
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-app-${{ github.event_name == 'workflow_dispatch' && inputs.channel || (github.ref_name == 'canary' && 'canary') || 'stable' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
channel-vars:
|
||||
uses: ./.github/workflows/channel-vars.yaml
|
||||
with:
|
||||
github_event_name: ${{ github.event_name }}
|
||||
github_ref_name: ${{ github.ref_name }}
|
||||
github_ref: ${{ github.ref }}
|
||||
workflow_dispatch_channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || '' }}
|
||||
workflow_dispatch_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
|
||||
|
||||
deploy:
|
||||
name: Deploy app
|
||||
needs: channel-vars
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
IS_CANARY: ${{ needs.channel-vars.outputs.is_canary }}
|
||||
SOURCE_REF: ${{ needs.channel-vars.outputs.source_ref }}
|
||||
STACK_SUFFIX: ${{ needs.channel-vars.outputs.stack_suffix }}
|
||||
|
||||
SERVICE_NAME: ${{ format('fluxer-app{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
DOCKERFILE: fluxer_app/proxy/Dockerfile
|
||||
SENTRY_PROXY_PATH: /error-reporting-proxy
|
||||
CACHE_SCOPE: ${{ format('fluxer-app{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
|
||||
PUBLIC_BOOTSTRAP_API_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://web.canary.fluxer.app/api' || 'https://web.fluxer.app/api' }}
|
||||
PUBLIC_BOOTSTRAP_API_PUBLIC_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://api.canary.fluxer.app' || 'https://api.fluxer.app' }}
|
||||
PUBLIC_PROJECT_ENV: ${{ needs.channel-vars.outputs.channel }}
|
||||
PUBLIC_SENTRY_DSN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://59ced0e2666ab83dd1ddb056cdd22d1b@sentry.web.canary.fluxer.app/4510205815291904' || 'https://59ced0e2666ab83dd1ddb056cdd22d1b@sentry.web.fluxer.app/4510205815291904' }}
|
||||
|
||||
SENTRY_REPORT_HOST: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://sentry.web.canary.fluxer.app' || 'https://sentry.web.fluxer.app' }}
|
||||
API_TARGET: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'fluxer-api-canary_app' || 'fluxer-api_app' }}
|
||||
|
||||
CADDY_APP_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'web.canary.fluxer.app' || 'web.fluxer.app' }}
|
||||
SENTRY_CADDY_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'sentry.web.canary.fluxer.app' || 'sentry.web.fluxer.app' }}
|
||||
|
||||
RELEASE_CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
APP_REPLICAS: ${{ needs.channel-vars.outputs.is_canary == 'true' && 1 || 2 }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.26.0
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
cache-dependency-path: fluxer_app/pnpm-lock.yaml
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: '1.25.5'
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: fluxer_app
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run Lingui i18n tasks
|
||||
working-directory: fluxer_app
|
||||
run: pnpm lingui:extract && pnpm lingui:compile --strict
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: wasm32-unknown-unknown
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
fluxer_app/crates/gif_wasm/target/
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('fluxer_app/crates/gif_wasm/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Install wasm-pack
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! command -v wasm-pack >/dev/null 2>&1; then
|
||||
cargo install wasm-pack --version 0.13.1
|
||||
fi
|
||||
|
||||
- name: Generate wasm artifacts
|
||||
working-directory: fluxer_app
|
||||
run: pnpm wasm:codegen
|
||||
|
||||
- name: Build application
|
||||
working-directory: fluxer_app
|
||||
env:
|
||||
NODE_ENV: production
|
||||
PUBLIC_BOOTSTRAP_API_ENDPOINT: ${{ env.PUBLIC_BOOTSTRAP_API_ENDPOINT }}
|
||||
PUBLIC_BOOTSTRAP_API_PUBLIC_ENDPOINT: ${{ env.PUBLIC_BOOTSTRAP_API_PUBLIC_ENDPOINT }}
|
||||
PUBLIC_API_VERSION: 1
|
||||
PUBLIC_PROJECT_ENV: ${{ env.PUBLIC_PROJECT_ENV }}
|
||||
PUBLIC_SENTRY_PROJECT_ID: 4510205815291904
|
||||
PUBLIC_SENTRY_PUBLIC_KEY: 59ced0e2666ab83dd1ddb056cdd22d1b
|
||||
PUBLIC_SENTRY_DSN: ${{ env.PUBLIC_SENTRY_DSN }}
|
||||
PUBLIC_SENTRY_PROXY_PATH: ${{ env.SENTRY_PROXY_PATH }}
|
||||
PUBLIC_BUILD_NUMBER: ${{ github.run_number }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PUBLIC_BUILD_SHA=$(git rev-parse --short HEAD)
|
||||
export PUBLIC_BUILD_TIMESTAMP=$(date +%s)
|
||||
pnpm build
|
||||
cat > dist/version.json << EOF
|
||||
{
|
||||
"sha": "$PUBLIC_BUILD_SHA",
|
||||
"buildNumber": $PUBLIC_BUILD_NUMBER,
|
||||
"timestamp": $PUBLIC_BUILD_TIMESTAMP,
|
||||
"env": "$PUBLIC_PROJECT_ENV"
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Install rclone
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! command -v rclone >/dev/null 2>&1; then
|
||||
curl -fsSL https://rclone.org/install.sh | sudo bash
|
||||
fi
|
||||
|
||||
- name: Upload assets to S3 static bucket
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.config/rclone
|
||||
cat > ~/.config/rclone/rclone.conf << RCLONEEOF
|
||||
[ovh]
|
||||
type = s3
|
||||
provider = Other
|
||||
env_auth = true
|
||||
endpoint = https://s3.us-east-va.io.cloud.ovh.us
|
||||
acl = public-read
|
||||
RCLONEEOF
|
||||
|
||||
rclone copy fluxer_app/dist/assets ovh:fluxer-static/assets \
|
||||
--transfers 32 \
|
||||
--checkers 16 \
|
||||
--size-only \
|
||||
--fast-list \
|
||||
--s3-upload-concurrency 8 \
|
||||
--s3-chunk-size 16M \
|
||||
-v
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ${{ env.DOCKERFILE }}
|
||||
tags: ${{ env.SERVICE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.SERVICE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
|
||||
SERVICE_NAME: ${{ env.SERVICE_NAME }}
|
||||
COMPOSE_STACK: ${{ env.SERVICE_NAME }}
|
||||
|
||||
SENTRY_DSN: https://59ced0e2666ab83dd1ddb056cdd22d1b@o4510149383094272.ingest.us.sentry.io/4510205815291904
|
||||
SENTRY_PROXY_PATH: ${{ env.SENTRY_PROXY_PATH }}
|
||||
SENTRY_REPORT_HOST: ${{ env.SENTRY_REPORT_HOST }}
|
||||
|
||||
CADDY_APP_DOMAIN: ${{ env.CADDY_APP_DOMAIN }}
|
||||
SENTRY_CADDY_DOMAIN: ${{ env.SENTRY_CADDY_DOMAIN }}
|
||||
API_TARGET: ${{ env.API_TARGET }}
|
||||
|
||||
RELEASE_CHANNEL: ${{ env.RELEASE_CHANNEL }}
|
||||
APP_REPLICAS: ${{ env.APP_REPLICAS }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" \
|
||||
"IMAGE_TAG=${IMAGE_TAG} SERVICE_NAME=${SERVICE_NAME} COMPOSE_STACK=${COMPOSE_STACK} SENTRY_DSN=${SENTRY_DSN} SENTRY_PROXY_PATH=${SENTRY_PROXY_PATH} SENTRY_REPORT_HOST=${SENTRY_REPORT_HOST} CADDY_APP_DOMAIN=${CADDY_APP_DOMAIN} SENTRY_CADDY_DOMAIN=${SENTRY_CADDY_DOMAIN} API_TARGET=${API_TARGET} RELEASE_CHANNEL=${RELEASE_CHANNEL} APP_REPLICAS=${APP_REPLICAS} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p "/opt/${SERVICE_NAME}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${SERVICE_NAME}"
|
||||
cd "/opt/${SERVICE_NAME}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
x-deploy-base: &deploy_base
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
x-common-caddy-headers: &common_caddy_headers
|
||||
caddy.header.Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
|
||||
caddy.header.X-Xss-Protection: "1; mode=block"
|
||||
caddy.header.X-Content-Type-Options: "nosniff"
|
||||
caddy.header.Referrer-Policy: "strict-origin-when-cross-origin"
|
||||
caddy.header.X-Frame-Options: "DENY"
|
||||
caddy.header.Expect-Ct: "max-age=86400, report-uri=\\"${SENTRY_REPORT_HOST}/api/4510205815291904/security/?sentry_key=59ced0e2666ab83dd1ddb056cdd22d1b\\""
|
||||
caddy.header.Cache-Control: "no-store, no-cache, must-revalidate"
|
||||
caddy.header.Pragma: "no-cache"
|
||||
caddy.header.Expires: "0"
|
||||
|
||||
x-env-base: &env_base
|
||||
PORT: 8080
|
||||
RELEASE_CHANNEL: ${RELEASE_CHANNEL}
|
||||
FLUXER_METRICS_HOST: fluxer-metrics_app:8080
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
SENTRY_REPORT_HOST: ${SENTRY_REPORT_HOST}
|
||||
|
||||
x-healthcheck: &healthcheck
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: ${APP_REPLICAS}
|
||||
labels:
|
||||
<<: *common_caddy_headers
|
||||
caddy: ${CADDY_APP_DOMAIN}
|
||||
caddy.handle_path_0: /api*
|
||||
caddy.handle_path_0.reverse_proxy: "http://${API_TARGET}:8080"
|
||||
caddy.reverse_proxy: "{{upstreams 8080}}"
|
||||
environment:
|
||||
<<: *env_base
|
||||
SENTRY_PROXY_PATH: ${SENTRY_PROXY_PATH}
|
||||
networks: [fluxer-shared]
|
||||
healthcheck: *healthcheck
|
||||
|
||||
sentry:
|
||||
image: ${IMAGE_TAG}
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: 1
|
||||
labels:
|
||||
<<: *common_caddy_headers
|
||||
caddy: ${SENTRY_CADDY_DOMAIN}
|
||||
caddy.reverse_proxy: "{{upstreams 8080}}"
|
||||
environment:
|
||||
<<: *env_base
|
||||
SENTRY_PROXY_PATH: /
|
||||
networks: [fluxer-shared]
|
||||
healthcheck: *healthcheck
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${COMPOSE_STACK}"
|
||||
EOF
|
||||
193
.github/workflows/deploy-docs.yaml
vendored
Normal file
193
.github/workflows/deploy-docs.yaml
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
name: deploy docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_docs/**
|
||||
- .github/workflows/deploy-docs.yaml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
description: Channel to deploy
|
||||
ref:
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
description: Optional git ref to deploy (defaults to main/canary based on channel)
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-docs-${{ github.event_name == 'workflow_dispatch' && inputs.channel || (github.ref_name == 'canary' && 'canary') || 'stable' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
channel-vars:
|
||||
uses: ./.github/workflows/channel-vars.yaml
|
||||
with:
|
||||
github_event_name: ${{ github.event_name }}
|
||||
github_ref_name: ${{ github.ref_name }}
|
||||
github_ref: ${{ github.ref }}
|
||||
workflow_dispatch_channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || '' }}
|
||||
workflow_dispatch_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
|
||||
|
||||
deploy:
|
||||
name: Deploy docs
|
||||
needs: channel-vars
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
IS_CANARY: ${{ needs.channel-vars.outputs.is_canary }}
|
||||
SOURCE_REF: ${{ needs.channel-vars.outputs.source_ref }}
|
||||
STACK_SUFFIX: ${{ needs.channel-vars.outputs.stack_suffix }}
|
||||
|
||||
STACK: ${{ format('fluxer-docs{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
CACHE_SCOPE: ${{ format('deploy-fluxer-docs{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
|
||||
CADDY_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'docs.canary.fluxer.app' || 'docs.fluxer.app' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: fluxer_docs
|
||||
file: fluxer_docs/Dockerfile
|
||||
tags: ${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.STACK }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
STACK: ${{ env.STACK }}
|
||||
CADDY_DOMAIN: ${{ env.CADDY_DOMAIN }}
|
||||
IS_CANARY: ${{ env.IS_CANARY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" "IMAGE_TAG=${IMAGE_TAG} STACK=${STACK} CADDY_DOMAIN=${CADDY_DOMAIN} IS_CANARY=${IS_CANARY} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
sudo mkdir -p "/opt/${STACK}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${STACK}"
|
||||
cd "/opt/${STACK}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
x-deploy-base: &deploy_base
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
deploy:
|
||||
<<: *deploy_base
|
||||
replicas: 2
|
||||
labels:
|
||||
caddy: "${CADDY_DOMAIN}"
|
||||
caddy.reverse_proxy: "{{upstreams 3000}}"
|
||||
COMPOSEEOF
|
||||
|
||||
if [[ "${IS_CANARY}" == "true" ]]; then
|
||||
cat >> compose.yaml << 'COMPOSEEOF'
|
||||
caddy.header.X-Robots-Tag: "noindex, nofollow, nosnippet, noimageindex"
|
||||
COMPOSEEOF
|
||||
fi
|
||||
|
||||
cat >> compose.yaml << 'COMPOSEEOF'
|
||||
caddy.header.Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
|
||||
caddy.header.X-Xss-Protection: "1; mode=block"
|
||||
caddy.header.X-Content-Type-Options: "nosniff"
|
||||
caddy.header.Referrer-Policy: "strict-origin-when-cross-origin"
|
||||
caddy.header.X-Frame-Options: "DENY"
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:3000']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${STACK}"
|
||||
EOF
|
||||
277
.github/workflows/deploy-gateway.yaml
vendored
Normal file
277
.github/workflows/deploy-gateway.yaml
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
name: deploy gateway
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- canary
|
||||
paths:
|
||||
- 'fluxer_gateway/**'
|
||||
|
||||
concurrency:
|
||||
group: deploy-gateway
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy (hot patch)
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: fluxer_gateway
|
||||
|
||||
- name: Set up Erlang
|
||||
uses: erlef/setup-beam@v1
|
||||
with:
|
||||
otp-version: '28'
|
||||
rebar3-version: '3.24.0'
|
||||
|
||||
- name: Compile
|
||||
working-directory: fluxer_gateway
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rebar3 as prod compile
|
||||
|
||||
- name: Set up SSH
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
GATEWAY_ADMIN_SECRET: ${{ secrets.GATEWAY_ADMIN_SECRET }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
CONTAINER_ID="$(ssh "${SERVER}" "docker ps -q --filter label=com.docker.swarm.service.name=fluxer-gateway_app | head -1")"
|
||||
if [ -z "${CONTAINER_ID}" ]; then
|
||||
echo "::error::No running container found for service fluxer-gateway_app"
|
||||
ssh "${SERVER}" "docker ps --filter 'name=fluxer-gateway_app' --format '{{.ID}} {{.Names}} {{.Status}}'" || true
|
||||
exit 1
|
||||
fi
|
||||
echo "Container: ${CONTAINER_ID}"
|
||||
|
||||
LOCAL_MD5_LINES="$(
|
||||
erl -noshell -eval '
|
||||
Files = filelib:wildcard("fluxer_gateway/_build/prod/lib/fluxer_gateway/ebin/*.beam"),
|
||||
lists:foreach(
|
||||
fun(F) ->
|
||||
{ok, {M, Md5}} = beam_lib:md5(F),
|
||||
Hex = binary:encode_hex(Md5, lowercase),
|
||||
io:format("~s ~s ~s~n", [atom_to_list(M), binary_to_list(Hex), F])
|
||||
end,
|
||||
Files
|
||||
),
|
||||
halt().'
|
||||
)"
|
||||
|
||||
REMOTE_MD5_LINES="$(
|
||||
ssh "${SERVER}" "docker exec ${CONTAINER_ID} /opt/fluxer_gateway/bin/fluxer_gateway eval '
|
||||
Mods = hot_reload:get_loaded_modules(),
|
||||
lists:foreach(
|
||||
fun(M) ->
|
||||
case hot_reload:get_module_info(M) of
|
||||
{ok, Info} ->
|
||||
V = maps:get(loaded_md5, Info),
|
||||
S = case V of
|
||||
null -> \"null\";
|
||||
B when is_binary(B) -> binary_to_list(B)
|
||||
end,
|
||||
io:format(\"~s ~s~n\", [atom_to_list(M), S]);
|
||||
_ ->
|
||||
ok
|
||||
end
|
||||
end,
|
||||
Mods
|
||||
),
|
||||
ok.
|
||||
' " | tr -d '\r'
|
||||
)"
|
||||
|
||||
LOCAL_MD5_FILE="$(mktemp)"
|
||||
REMOTE_MD5_FILE="$(mktemp)"
|
||||
CHANGED_FILE_LIST="$(mktemp)"
|
||||
CHANGED_MAIN_LIST="$(mktemp)"
|
||||
CHANGED_SELF_LIST="$(mktemp)"
|
||||
RELOAD_RESULT_MAIN="$(mktemp)"
|
||||
RELOAD_RESULT_SELF="$(mktemp)"
|
||||
trap 'rm -f "${LOCAL_MD5_FILE}" "${REMOTE_MD5_FILE}" "${CHANGED_FILE_LIST}" "${CHANGED_MAIN_LIST}" "${CHANGED_SELF_LIST}" "${RELOAD_RESULT_MAIN}" "${RELOAD_RESULT_SELF}"' EXIT
|
||||
|
||||
printf '%s' "${LOCAL_MD5_LINES}" > "${LOCAL_MD5_FILE}"
|
||||
printf '%s' "${REMOTE_MD5_LINES}" > "${REMOTE_MD5_FILE}"
|
||||
|
||||
python3 - <<'PY' "${LOCAL_MD5_FILE}" "${REMOTE_MD5_FILE}" "${CHANGED_FILE_LIST}"
|
||||
import sys
|
||||
|
||||
local_path, remote_path, out_path = sys.argv[1:4]
|
||||
|
||||
remote = {}
|
||||
with open(remote_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split(None, 1)
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
mod, md5 = parts
|
||||
remote[mod] = md5.strip()
|
||||
|
||||
changed_paths = []
|
||||
with open(local_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split(" ", 2)
|
||||
if len(parts) != 3:
|
||||
continue
|
||||
mod, md5, path = parts
|
||||
r = remote.get(mod)
|
||||
if r is None or r == "null" or r != md5:
|
||||
changed_paths.append(path)
|
||||
|
||||
with open(out_path, "w", encoding="utf-8") as f:
|
||||
for p in changed_paths:
|
||||
f.write(p + "\n")
|
||||
PY
|
||||
|
||||
mapfile -t CHANGED_FILES < "${CHANGED_FILE_LIST}"
|
||||
|
||||
if [ "${#CHANGED_FILES[@]}" -eq 0 ]; then
|
||||
echo "No BEAM changes detected, nothing to hot-reload."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Changed modules count: ${#CHANGED_FILES[@]}"
|
||||
|
||||
while IFS= read -r p; do
|
||||
[ -n "${p}" ] || continue
|
||||
m="$(basename "${p}")"
|
||||
m="${m%.beam}"
|
||||
if [ "${m}" = "hot_reload" ] || [ "${m}" = "hot_reload_handler" ]; then
|
||||
printf '%s\n' "${p}" >> "${CHANGED_SELF_LIST}"
|
||||
else
|
||||
printf '%s\n' "${p}" >> "${CHANGED_MAIN_LIST}"
|
||||
fi
|
||||
done < "${CHANGED_FILE_LIST}"
|
||||
|
||||
build_json() {
|
||||
python3 - "$1" <<'PY'
|
||||
import sys, json, base64, os
|
||||
list_path = sys.argv[1]
|
||||
beams = []
|
||||
with open(list_path, "r", encoding="utf-8") as f:
|
||||
for path in f:
|
||||
path = path.strip()
|
||||
if not path:
|
||||
continue
|
||||
mod = os.path.basename(path)
|
||||
if not mod.endswith(".beam"):
|
||||
continue
|
||||
mod = mod[:-5]
|
||||
with open(path, "rb") as bf:
|
||||
b = bf.read()
|
||||
beams.append({"module": mod, "beam_b64": base64.b64encode(b).decode("ascii")})
|
||||
print(json.dumps({"beams": beams, "purge": "soft"}, separators=(",", ":")))
|
||||
PY
|
||||
}
|
||||
|
||||
strict_verify() {
|
||||
python3 -c '
|
||||
import json, sys
|
||||
raw = sys.stdin.read()
|
||||
if not raw.strip():
|
||||
print("::error::Empty reload response")
|
||||
raise SystemExit(1)
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
except Exception as e:
|
||||
print(f"::error::Invalid JSON reload response: {e}")
|
||||
raise SystemExit(1)
|
||||
results = data.get("results", [])
|
||||
if not isinstance(results, list):
|
||||
print("::error::Reload response missing results array")
|
||||
raise SystemExit(1)
|
||||
bad = [
|
||||
r for r in results
|
||||
if r.get("status") != "ok"
|
||||
or r.get("verified") is not True
|
||||
or r.get("purged_old_code") is not True
|
||||
or (r.get("lingering_count") or 0) != 0
|
||||
]
|
||||
if bad:
|
||||
print("::error::Hot reload verification failed")
|
||||
print(json.dumps(bad, indent=2))
|
||||
raise SystemExit(1)
|
||||
print(f"Verified {len(results)} modules")
|
||||
'
|
||||
}
|
||||
|
||||
self_verify() {
|
||||
python3 -c '
|
||||
import json, sys
|
||||
raw = sys.stdin.read()
|
||||
if not raw.strip():
|
||||
print("::error::Empty reload response")
|
||||
raise SystemExit(1)
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
except Exception as e:
|
||||
print(f"::error::Invalid JSON reload response: {e}")
|
||||
raise SystemExit(1)
|
||||
results = data.get("results", [])
|
||||
if not isinstance(results, list):
|
||||
print("::error::Reload response missing results array")
|
||||
raise SystemExit(1)
|
||||
bad = [
|
||||
r for r in results
|
||||
if r.get("status") != "ok"
|
||||
or r.get("verified") is not True
|
||||
]
|
||||
if bad:
|
||||
print("::error::Hot reload verification failed")
|
||||
print(json.dumps(bad, indent=2))
|
||||
raise SystemExit(1)
|
||||
warns = [
|
||||
r for r in results
|
||||
if r.get("purged_old_code") is not True
|
||||
or (r.get("lingering_count") or 0) != 0
|
||||
]
|
||||
if warns:
|
||||
print("::warning::Self-reload modules may linger until request completes")
|
||||
print(json.dumps(warns, indent=2))
|
||||
print(f"Verified {len(results)} self modules")
|
||||
'
|
||||
}
|
||||
|
||||
if [ -s "${CHANGED_MAIN_LIST}" ]; then
|
||||
if ! build_json "${CHANGED_MAIN_LIST}" | ssh "${SERVER}" "docker exec -i ${CONTAINER_ID} curl -fsS -X POST -H 'Authorization: Bearer ${GATEWAY_ADMIN_SECRET}' -H 'Content-Type: application/json' --data @- http://localhost:8081/_admin/reload" | tee "${RELOAD_RESULT_MAIN}" | strict_verify; then
|
||||
echo "::group::Hot reload response (main)"
|
||||
cat "${RELOAD_RESULT_MAIN}" || true
|
||||
echo "::endgroup::"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -s "${CHANGED_SELF_LIST}" ]; then
|
||||
if ! build_json "${CHANGED_SELF_LIST}" | ssh "${SERVER}" "docker exec -i ${CONTAINER_ID} curl -fsS -X POST -H 'Authorization: Bearer ${GATEWAY_ADMIN_SECRET}' -H 'Content-Type: application/json' --data @- http://localhost:8081/_admin/reload" | tee "${RELOAD_RESULT_SELF}" | self_verify; then
|
||||
echo "::group::Hot reload response (self)"
|
||||
cat "${RELOAD_RESULT_SELF}" || true
|
||||
echo "::endgroup::"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
240
.github/workflows/deploy-marketing.yaml
vendored
Normal file
240
.github/workflows/deploy-marketing.yaml
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
name: deploy marketing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_marketing/**
|
||||
- .github/workflows/deploy-marketing.yaml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- canary
|
||||
default: stable
|
||||
description: Channel to deploy
|
||||
ref:
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
description: Optional git ref to deploy (defaults to main/canary based on channel)
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-marketing-${{ github.event_name == 'workflow_dispatch' && inputs.channel || (github.ref_name == 'canary' && 'canary') || 'stable' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
channel-vars:
|
||||
uses: ./.github/workflows/channel-vars.yaml
|
||||
with:
|
||||
github_event_name: ${{ github.event_name }}
|
||||
github_ref_name: ${{ github.ref_name }}
|
||||
github_ref: ${{ github.ref }}
|
||||
workflow_dispatch_channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || '' }}
|
||||
workflow_dispatch_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
|
||||
|
||||
deploy:
|
||||
name: Deploy marketing
|
||||
needs: channel-vars
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
IS_CANARY: ${{ needs.channel-vars.outputs.is_canary }}
|
||||
SOURCE_REF: ${{ needs.channel-vars.outputs.source_ref }}
|
||||
STACK_SUFFIX: ${{ needs.channel-vars.outputs.stack_suffix }}
|
||||
STACK: ${{ format('fluxer-marketing{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
IMAGE_NAME: ${{ format('fluxer-marketing{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
CACHE_SCOPE: ${{ format('deploy-fluxer-marketing{0}', needs.channel-vars.outputs.stack_suffix) }}
|
||||
APP_REPLICAS: ${{ needs.channel-vars.outputs.is_canary == 'true' && 1 || 2 }}
|
||||
API_PUBLIC_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://api.canary.fluxer.app' || 'https://api.fluxer.app' }}
|
||||
API_HOST: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'fluxer-api-canary_app:8080' || 'fluxer-api_app:8080' }}
|
||||
APP_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://web.canary.fluxer.app' || 'https://web.fluxer.app' }}
|
||||
MARKETING_ENDPOINT: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'https://canary.fluxer.app' || 'https://fluxer.app' }}
|
||||
CADDY_DOMAIN: ${{ needs.channel-vars.outputs.is_canary == 'true' && 'canary.fluxer.app' || 'fluxer.app' }}
|
||||
RELEASE_CHANNEL: ${{ needs.channel-vars.outputs.channel }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.SOURCE_REF }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |-
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set build timestamp
|
||||
run: echo "BUILD_TIMESTAMP=$(date -u +%s)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: fluxer_marketing
|
||||
file: fluxer_marketing/Dockerfile
|
||||
tags: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}
|
||||
build-args: |
|
||||
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |-
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |-
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
STACK: ${{ env.STACK }}
|
||||
IS_CANARY: ${{ env.IS_CANARY }}
|
||||
API_PUBLIC_ENDPOINT: ${{ env.API_PUBLIC_ENDPOINT }}
|
||||
API_HOST: ${{ env.API_HOST }}
|
||||
APP_ENDPOINT: ${{ env.APP_ENDPOINT }}
|
||||
MARKETING_ENDPOINT: ${{ env.MARKETING_ENDPOINT }}
|
||||
CADDY_DOMAIN: ${{ env.CADDY_DOMAIN }}
|
||||
RELEASE_CHANNEL: ${{ env.RELEASE_CHANNEL }}
|
||||
APP_REPLICAS: ${{ env.APP_REPLICAS }}
|
||||
run: |-
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" \
|
||||
"IMAGE_TAG=${IMAGE_TAG} STACK=${STACK} IS_CANARY=${IS_CANARY} API_PUBLIC_ENDPOINT=${API_PUBLIC_ENDPOINT} API_HOST=${API_HOST} APP_ENDPOINT=${APP_ENDPOINT} MARKETING_ENDPOINT=${MARKETING_ENDPOINT} CADDY_DOMAIN=${CADDY_DOMAIN} RELEASE_CHANNEL=${RELEASE_CHANNEL} APP_REPLICAS=${APP_REPLICAS} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
sudo mkdir -p "/opt/${STACK}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${STACK}"
|
||||
cd "/opt/${STACK}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- FLUXER_API_PUBLIC_ENDPOINT=${API_PUBLIC_ENDPOINT}
|
||||
- FLUXER_API_HOST=${API_HOST}
|
||||
- FLUXER_APP_ENDPOINT=${APP_ENDPOINT}
|
||||
- FLUXER_CDN_ENDPOINT=https://fluxerstatic.com
|
||||
- FLUXER_MARKETING_ENDPOINT=${MARKETING_ENDPOINT}
|
||||
- FLUXER_MARKETING_PORT=8080
|
||||
- FLUXER_PATH_MARKETING=/
|
||||
- RELEASE_CHANNEL=${RELEASE_CHANNEL}
|
||||
- FLUXER_METRICS_HOST=fluxer-metrics_app:8080
|
||||
deploy:
|
||||
replicas: ${APP_REPLICAS}
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
labels:
|
||||
caddy: "${CADDY_DOMAIN}"
|
||||
caddy.reverse_proxy: "{{upstreams 8080}}"
|
||||
caddy.header.Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
|
||||
caddy.header.X-Xss-Protection: "1; mode=block"
|
||||
caddy.header.X-Content-Type-Options: "nosniff"
|
||||
caddy.header.Referrer-Policy: "strict-origin-when-cross-origin"
|
||||
caddy.header.X-Frame-Options: "DENY"
|
||||
COMPOSEEOF
|
||||
|
||||
if [[ "${IS_CANARY}" == "true" ]]; then
|
||||
cat >> compose.yaml << 'COMPOSEEOF'
|
||||
caddy.header.X-Robots-Tag: "noindex, nofollow, nosnippet, noimageindex"
|
||||
caddy.@channels.path: "/channels /channels/*"
|
||||
caddy.redir: "@channels https://web.canary.fluxer.app{uri}"
|
||||
COMPOSEEOF
|
||||
else
|
||||
cat >> compose.yaml << 'COMPOSEEOF'
|
||||
caddy.redir_0: "/channels/* https://web.fluxer.app{uri}"
|
||||
caddy.redir_1: "/channels https://web.fluxer.app{uri}"
|
||||
caddy.redir_2: "/delete-my-account https://fluxer.app/help/articles/1445724566704881664 302"
|
||||
caddy.redir_3: "/delete-my-data https://fluxer.app/help/articles/1445730947679911936 302"
|
||||
caddy.redir_4: "/export-my-data https://fluxer.app/help/articles/1445731738851475456 302"
|
||||
caddy.redir_5: "/bugs https://fluxer.app/help/articles/1447264362996695040 302"
|
||||
caddy_1: "www.fluxer.app"
|
||||
caddy_1.redir: "https://fluxer.app{uri}"
|
||||
caddy_3: "fluxer.gg"
|
||||
caddy_3.redir: "https://web.fluxer.app/invite{uri}"
|
||||
caddy_4: "fluxer.gift"
|
||||
caddy_4.redir: "https://web.fluxer.app/gift{uri}"
|
||||
caddy_5: "fluxerapp.com"
|
||||
caddy_5.redir: "https://fluxer.app{uri}"
|
||||
caddy_6: "www.fluxerapp.com"
|
||||
caddy_6.redir: "https://fluxer.app{uri}"
|
||||
caddy_7: "fluxer.dev"
|
||||
caddy_7.redir: "https://docs.fluxer.app{uri}"
|
||||
caddy_8: "www.fluxer.dev"
|
||||
caddy_8.redir: "https://docs.fluxer.app{uri}"
|
||||
COMPOSEEOF
|
||||
fi
|
||||
|
||||
cat >> compose.yaml << 'COMPOSEEOF'
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy \
|
||||
--with-registry-auth \
|
||||
--detach=false \
|
||||
--resolve-image never \
|
||||
-c compose.yaml \
|
||||
"${STACK}"
|
||||
EOF
|
||||
150
.github/workflows/deploy-media-proxy.yaml
vendored
Normal file
150
.github/workflows/deploy-media-proxy.yaml
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
name: deploy media-proxy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- fluxer_media_proxy/**
|
||||
- .github/workflows/deploy-media-proxy.yaml
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-media-proxy
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
SERVICE_NAME: fluxer-media-proxy
|
||||
IMAGE_NAME: fluxer-media-proxy
|
||||
CONTEXT_DIR: fluxer_media_proxy
|
||||
COMPOSE_STACK: fluxer-media-proxy
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy media proxy
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ${{ env.CONTEXT_DIR }}
|
||||
file: ${{ env.CONTEXT_DIR }}/Dockerfile
|
||||
tags: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.SERVICE_NAME }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.SERVICE_NAME }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" "IMAGE_TAG=${IMAGE_TAG} SERVICE_NAME=${SERVICE_NAME} COMPOSE_STACK=${COMPOSE_STACK} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p "/opt/${SERVICE_NAME}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${SERVICE_NAME}"
|
||||
cd "/opt/${SERVICE_NAME}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
command: ['pnpm', 'start']
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- FLUXER_MEDIA_PROXY_PORT=8080
|
||||
- FLUXER_MEDIA_PROXY_REQUIRE_CLOUDFLARE=true
|
||||
- SENTRY_DSN=https://2670068cd12b6a62f3a30a7f0055f0f1@o4510149383094272.ingest.us.sentry.io/4510205811556352
|
||||
- AWS_S3_ENDPOINT=https://s3.us-east-va.io.cloud.ovh.us
|
||||
- AWS_S3_BUCKET_CDN=fluxer
|
||||
- AWS_S3_BUCKET_UPLOADS=fluxer-uploads
|
||||
- FLUXER_METRICS_HOST=fluxer-metrics_app:8080
|
||||
deploy:
|
||||
replicas: 2
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
labels:
|
||||
- 'caddy=http://fluxerusercontent.com'
|
||||
- 'caddy.reverse_proxy={{upstreams 8080}}'
|
||||
- 'caddy.header.X-Robots-Tag="noindex, nofollow, nosnippet, noimageindex"'
|
||||
- 'caddy.header.Strict-Transport-Security="max-age=31536000; includeSubDomains; preload"'
|
||||
- 'caddy.header.X-Xss-Protection="1; mode=block"'
|
||||
- 'caddy.header.X-Content-Type-Options=nosniff'
|
||||
- 'caddy.header.Referrer-Policy=strict-origin-when-cross-origin'
|
||||
- 'caddy.header.X-Frame-Options=DENY'
|
||||
- 'caddy.header.Expect-Ct="max-age=86400, report-uri=\"https://o4510149383094272.ingest.us.sentry.io/api/4510205811556352/security/?sentry_key=2670068cd12b6a62f3a30a7f0055f0f1\""'
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy --with-registry-auth --detach=false --resolve-image never -c compose.yaml "${COMPOSE_STACK}"
|
||||
EOF
|
||||
131
.github/workflows/deploy-metrics.yaml
vendored
Normal file
131
.github/workflows/deploy-metrics.yaml
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
name: deploy metrics
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- fluxer_metrics/**
|
||||
- .github/workflows/deploy-metrics.yaml
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-metrics
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy metrics
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: fluxer_metrics
|
||||
file: fluxer_metrics/Dockerfile
|
||||
tags: fluxer-metrics:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=deploy-fluxer-metrics
|
||||
cache-to: type=gha,mode=max,scope=deploy-fluxer-metrics
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: fluxer-metrics:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" "IMAGE_TAG=${IMAGE_TAG} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p /opt/fluxer-metrics
|
||||
sudo chown -R "${USER}:${USER}" /opt/fluxer-metrics
|
||||
cd /opt/fluxer-metrics
|
||||
|
||||
cat > compose.yaml << 'COMPOSEEOF'
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- METRICS_PORT=8080
|
||||
- CLICKHOUSE_URL=http://clickhouse:8123
|
||||
- CLICKHOUSE_DATABASE=fluxer_metrics
|
||||
- CLICKHOUSE_USER=fluxer
|
||||
- FLUXER_ADMIN_ENDPOINT=https://admin.fluxer.app
|
||||
- ANOMALY_DETECTION_ENABLED=true
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy --with-registry-auth --detach=false --resolve-image never -c compose.yaml fluxer-metrics
|
||||
EOF
|
||||
150
.github/workflows/deploy-static-proxy.yaml
vendored
Normal file
150
.github/workflows/deploy-static-proxy.yaml
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
name: deploy static-proxy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- fluxer_media_proxy/**
|
||||
- .github/workflows/deploy-static-proxy.yaml
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: deploy-fluxer-static-proxy
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
SERVICE_NAME: fluxer-static-proxy
|
||||
IMAGE_NAME: fluxer-static-proxy
|
||||
CONTEXT_DIR: fluxer_media_proxy
|
||||
COMPOSE_STACK: fluxer-static-proxy
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy static proxy
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ${{ env.CONTEXT_DIR }}
|
||||
file: ${{ env.CONTEXT_DIR }}/Dockerfile
|
||||
tags: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.SERVICE_NAME }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.SERVICE_NAME }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" "IMAGE_TAG=${IMAGE_TAG} SERVICE_NAME=${SERVICE_NAME} COMPOSE_STACK=${COMPOSE_STACK} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p "/opt/${SERVICE_NAME}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${SERVICE_NAME}"
|
||||
cd "/opt/${SERVICE_NAME}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
command: ['pnpm', 'start']
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- FLUXER_MEDIA_PROXY_PORT=8080
|
||||
- FLUXER_MEDIA_PROXY_STATIC_MODE=true
|
||||
- FLUXER_MEDIA_PROXY_REQUIRE_CLOUDFLARE=true
|
||||
- AWS_S3_ENDPOINT=https://s3.us-east-va.io.cloud.ovh.us
|
||||
- AWS_S3_BUCKET_CDN=fluxer
|
||||
- AWS_S3_BUCKET_UPLOADS=fluxer-uploads
|
||||
- AWS_S3_BUCKET_STATIC=fluxer-static
|
||||
deploy:
|
||||
replicas: 2
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
labels:
|
||||
- 'caddy=http://fluxerstatic.com'
|
||||
- 'caddy.reverse_proxy={{upstreams 8080}}'
|
||||
- 'caddy.header.X-Robots-Tag="noindex, nofollow, nosnippet, noimageindex"'
|
||||
- 'caddy.header.Strict-Transport-Security="max-age=31536000; includeSubDomains; preload"'
|
||||
- 'caddy.header.X-Xss-Protection="1; mode=block"'
|
||||
- 'caddy.header.X-Content-Type-Options=nosniff'
|
||||
- 'caddy.header.Referrer-Policy=strict-origin-when-cross-origin'
|
||||
- 'caddy.header.X-Frame-Options=DENY'
|
||||
- 'caddy.header.Expect-Ct="max-age=86400, report-uri=\"https://o4510149383094272.ingest.us.sentry.io/api/4510205811556352/security/?sentry_key=2670068cd12b6a62f3a30a7f0055f0f1\""'
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy --with-registry-auth --detach=false --resolve-image never -c compose.yaml "${COMPOSE_STACK}"
|
||||
EOF
|
||||
125
.github/workflows/migrate-cassandra.yaml
vendored
Normal file
125
.github/workflows/migrate-cassandra.yaml
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
name: migrate cassandra
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- canary
|
||||
paths:
|
||||
- fluxer_devops/cassandra/migrations/**/*.cql
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: migrate-cassandra-prod
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
migrate:
|
||||
name: Run database migrations
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
scripts/cassandra-migrate/target/
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('scripts/cassandra-migrate/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Build migration tool
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd scripts/cassandra-migrate
|
||||
cargo build --release
|
||||
|
||||
- name: Validate migrations
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./scripts/cassandra-migrate/target/release/cassandra-migrate check
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Set up SSH tunnel for Cassandra
|
||||
run: |
|
||||
set -euo pipefail
|
||||
nohup ssh -N -o ConnectTimeout=30 -o ServerAliveInterval=10 -o ServerAliveCountMax=30 -o ExitOnForwardFailure=yes -L 9042:localhost:9042 ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} > /tmp/ssh-tunnel.log 2>&1 &
|
||||
SSH_TUNNEL_PID=$!
|
||||
printf 'SSH_TUNNEL_PID=%s\n' "$SSH_TUNNEL_PID" >> "$GITHUB_ENV"
|
||||
|
||||
for i in {1..30}; do
|
||||
if timeout 1 bash -c "echo > /dev/tcp/localhost/9042" 2>/dev/null; then
|
||||
echo "SSH tunnel established"
|
||||
break
|
||||
elif command -v ss >/dev/null 2>&1 && ss -tln | grep -q ":9042 "; then
|
||||
echo "SSH tunnel established"
|
||||
break
|
||||
elif command -v netstat >/dev/null 2>&1 && netstat -tln | grep -q ":9042 "; then
|
||||
echo "SSH tunnel established"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
cat /tmp/ssh-tunnel.log || true
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
ps -p $SSH_TUNNEL_PID > /dev/null || exit 1
|
||||
|
||||
- name: Test Cassandra connection
|
||||
env:
|
||||
CASSANDRA_USERNAME: ${{ secrets.CASSANDRA_USERNAME }}
|
||||
CASSANDRA_PASSWORD: ${{ secrets.CASSANDRA_PASSWORD }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./scripts/cassandra-migrate/target/release/cassandra-migrate \
|
||||
--host localhost \
|
||||
--port 9042 \
|
||||
--username "${CASSANDRA_USERNAME}" \
|
||||
--password "${CASSANDRA_PASSWORD}" \
|
||||
test
|
||||
|
||||
- name: Run migrations
|
||||
env:
|
||||
CASSANDRA_USERNAME: ${{ secrets.CASSANDRA_USERNAME }}
|
||||
CASSANDRA_PASSWORD: ${{ secrets.CASSANDRA_PASSWORD }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./scripts/cassandra-migrate/target/release/cassandra-migrate \
|
||||
--host localhost \
|
||||
--port 9042 \
|
||||
--username "${CASSANDRA_USERNAME}" \
|
||||
--password "${CASSANDRA_PASSWORD}" \
|
||||
up
|
||||
|
||||
- name: Close SSH tunnel
|
||||
if: always()
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -n "${SSH_TUNNEL_PID:-}" ]; then
|
||||
kill "$SSH_TUNNEL_PID" 2>/dev/null || true
|
||||
fi
|
||||
pkill -f "ssh.*9042:localhost:9042" || true
|
||||
rm -f /tmp/ssh-tunnel.log || true
|
||||
93
.github/workflows/promote-canary-to-main.yaml
vendored
Normal file
93
.github/workflows/promote-canary-to-main.yaml
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
name: promote canary -> main
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Show what would change, but don't push"
|
||||
src:
|
||||
type: string
|
||||
default: canary
|
||||
description: 'Source branch'
|
||||
dst:
|
||||
type: string
|
||||
default: main
|
||||
description: 'Destination branch'
|
||||
|
||||
concurrency:
|
||||
group: promote-${{ inputs.dst }}
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
promote:
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Create GitHub App token
|
||||
id: app-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.PROMOTE_APP_ID }}
|
||||
private-key: ${{ secrets.PROMOTE_APP_PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.src }}
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
|
||||
- name: Verify ff-only + summarize
|
||||
id: verify
|
||||
run: |
|
||||
set -euo pipefail
|
||||
src="${{ inputs.src }}"
|
||||
dst="${{ inputs.dst }}"
|
||||
|
||||
git fetch origin "${dst}" "${src}" --prune
|
||||
|
||||
# Ensure HEAD is exactly origin/src
|
||||
git reset --hard "origin/${src}"
|
||||
|
||||
# FF-only requirement: dst must be an ancestor of src
|
||||
if ! git merge-base --is-ancestor "origin/${dst}" "origin/${src}"; then
|
||||
echo "::error::Cannot fast-forward: origin/${dst} is not an ancestor of origin/${src} (branches diverged)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ahead="$(git rev-list --count "origin/${dst}..origin/${src}")"
|
||||
echo "ahead=$ahead" >> "$GITHUB_OUTPUT"
|
||||
|
||||
{
|
||||
echo "## Promote \`${src}\` → \`${dst}\` (ff-only)"
|
||||
echo ""
|
||||
echo "- \`${dst}\`: \`$(git rev-parse "origin/${dst}")\`"
|
||||
echo "- \`${src}\`: \`$(git rev-parse "origin/${src}")\`"
|
||||
echo "- Commits to promote: **${ahead}**"
|
||||
echo ""
|
||||
echo "### Commits"
|
||||
if [ "$ahead" -eq 0 ]; then
|
||||
echo "_Nothing to promote._"
|
||||
else
|
||||
git log --oneline --decorate "origin/${dst}..origin/${src}"
|
||||
fi
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Push fast-forward
|
||||
if: ${{ steps.verify.outputs.ahead != '0' && inputs.dry_run != true }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
dst="${{ inputs.dst }}"
|
||||
# Push src HEAD to dst (no merge commit, same SHAs)
|
||||
git push origin "HEAD:refs/heads/${dst}"
|
||||
|
||||
- name: Dry run / no-op
|
||||
if: ${{ steps.verify.outputs.ahead == '0' || inputs.dry_run == true }}
|
||||
run: |
|
||||
echo "No push performed (dry_run=${{ inputs.dry_run }}, ahead=${{ steps.verify.outputs.ahead }})."
|
||||
149
.github/workflows/restart-gateway.yaml
vendored
Normal file
149
.github/workflows/restart-gateway.yaml
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
name: restart gateway
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
confirmation:
|
||||
description: this will cause service interruption for all users. type RESTART to confirm.
|
||||
required: true
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: restart-gateway
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
SERVICE_NAME: fluxer-gateway
|
||||
IMAGE_NAME: fluxer-gateway
|
||||
CONTEXT_DIR: fluxer_gateway
|
||||
COMPOSE_STACK: fluxer-gateway
|
||||
|
||||
jobs:
|
||||
restart:
|
||||
name: Restart gateway
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Validate confirmation
|
||||
if: ${{ github.event.inputs.confirmation != 'RESTART' }}
|
||||
run: |
|
||||
echo "::error::Confirmation failed. You must type 'RESTART' to proceed with a full restart."
|
||||
echo "::error::For regular updates, use deploy-gateway.yaml instead."
|
||||
exit 1
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Record deploy commit
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "Deploying commit ${sha}"
|
||||
printf 'DEPLOY_SHA=%s\n' "$sha" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ${{ env.CONTEXT_DIR }}
|
||||
file: ${{ env.CONTEXT_DIR }}/Dockerfile
|
||||
tags: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
load: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha,scope=${{ env.SERVICE_NAME }}
|
||||
cache-to: type=gha,mode=max,scope=${{ env.SERVICE_NAME }}
|
||||
env:
|
||||
DOCKER_BUILD_SUMMARY: false
|
||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||
|
||||
- name: Install docker-pussh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL https://raw.githubusercontent.com/psviderski/unregistry/v0.3.1/docker-pussh \
|
||||
-o ~/.docker/cli-plugins/docker-pussh
|
||||
chmod +x ~/.docker/cli-plugins/docker-pussh
|
||||
|
||||
- name: Set up SSH agent
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_SERVER }}
|
||||
|
||||
- name: Add server to known hosts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Push image and deploy
|
||||
env:
|
||||
IMAGE_TAG: ${{ env.IMAGE_NAME }}:${{ env.DEPLOY_SHA }}
|
||||
SERVER: ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker pussh "${IMAGE_TAG}" "${SERVER}"
|
||||
|
||||
ssh "${SERVER}" "IMAGE_TAG=${IMAGE_TAG} SERVICE_NAME=${SERVICE_NAME} COMPOSE_STACK=${COMPOSE_STACK} bash" << 'EOF'
|
||||
set -euo pipefail
|
||||
sudo mkdir -p "/opt/${SERVICE_NAME}"
|
||||
sudo chown -R "${USER}:${USER}" "/opt/${SERVICE_NAME}"
|
||||
cd "/opt/${SERVICE_NAME}"
|
||||
|
||||
cat > compose.yaml << COMPOSEEOF
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_TAG}
|
||||
hostname: "{{.Node.Hostname}}-{{.Task.Slot}}"
|
||||
env_file:
|
||||
- /etc/fluxer/fluxer.env
|
||||
environment:
|
||||
- API_HOST=fluxer-api_app:8080
|
||||
- API_CANARY_HOST=fluxer-api-canary_app:8080
|
||||
- RELEASE_NODE=fluxer_gateway@{{.Node.Hostname}}-{{.Task.Slot}}
|
||||
- LOGGER_LEVEL=info
|
||||
- VAPID_PUBLIC_KEY=BEIwQxIwfj6m90tLYAR0AU_GJWU4kw8J_zJcHQG55NCUWSyRy-dzMOgvxk8yEDwdVyJZa6xUL4fmwngijq8T2pY
|
||||
- FLUXER_METRICS_HOST=fluxer-metrics_app:8080
|
||||
- MEDIA_PROXY_ENDPOINT=https://fluxerusercontent.com
|
||||
deploy:
|
||||
replicas: 1
|
||||
endpoint_mode: dnsrr
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
order: start-first
|
||||
rollback_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
labels:
|
||||
- 'caddy_gw=gateway.fluxer.app'
|
||||
- 'caddy_gw.reverse_proxy={{upstreams 8080}}'
|
||||
networks:
|
||||
- fluxer-shared
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:8080/_health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
networks:
|
||||
fluxer-shared:
|
||||
external: true
|
||||
COMPOSEEOF
|
||||
|
||||
docker stack deploy --with-registry-auth --detach=false --resolve-image never -c compose.yaml "${COMPOSE_STACK}"
|
||||
EOF
|
||||
59
.github/workflows/sync-static.yaml
vendored
Normal file
59
.github/workflows/sync-static.yaml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: sync static-bucket
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'fluxer_static/**'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: sync-fluxer-static
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
env:
|
||||
RCLONE_REMOTE: ovh
|
||||
RCLONE_BUCKET: fluxer-static
|
||||
RCLONE_SOURCE: fluxer_static
|
||||
RCLONE_ENDPOINT: https://s3.us-east-va.io.cloud.ovh.us
|
||||
RCLONE_REGION: us-east-1
|
||||
RCLONE_SOURCE_DIR: fluxer_static
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
lfs: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install rclone
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! command -v rclone >/dev/null 2>&1; then
|
||||
curl -fsSL https://rclone.org/install.sh | sudo bash
|
||||
fi
|
||||
|
||||
- name: Push repo contents to bucket
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.config/rclone
|
||||
cat > ~/.config/rclone/rclone.conf << RCLONEEOF
|
||||
[ovh]
|
||||
type = s3
|
||||
provider = Other
|
||||
env_auth = true
|
||||
endpoint = $RCLONE_ENDPOINT
|
||||
acl = private
|
||||
RCLONEEOF
|
||||
|
||||
mkdir -p "$RCLONE_SOURCE_DIR"
|
||||
rclone sync "$RCLONE_SOURCE" "$RCLONE_REMOTE:$RCLONE_BUCKET" --create-empty-src-dirs --exclude "assets/**"
|
||||
306
.github/workflows/test-cassandra-backup.yaml
vendored
Normal file
306
.github/workflows/test-cassandra-backup.yaml
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
name: test cassandra-backup
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 */2 * * *'
|
||||
|
||||
concurrency:
|
||||
group: test-cassandra-backup
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-backup:
|
||||
name: Test latest Cassandra backup
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 45
|
||||
|
||||
env:
|
||||
CASSANDRA_IMAGE: cassandra:5.0.6
|
||||
CASS_CONTAINER: cass-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
UTIL_CONTAINER: cass-util-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
CASS_VOLUME: cassandra-data-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
BACKUP_VOLUME: cassandra-backup-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
MAX_HEAP_SIZE: 2G
|
||||
HEAP_NEWSIZE: 512M
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set temp paths
|
||||
run: |
|
||||
set -euo pipefail
|
||||
: "${RUNNER_TEMP:?RUNNER_TEMP is not set}"
|
||||
echo "WORKDIR=$RUNNER_TEMP/cassandra-restore-test" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Pre-clean
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker rm -f "${CASS_CONTAINER}" "${UTIL_CONTAINER}" 2>/dev/null || true
|
||||
docker volume rm "${CASS_VOLUME}" 2>/dev/null || true
|
||||
docker volume rm "${BACKUP_VOLUME}" 2>/dev/null || true
|
||||
rm -rf "${WORKDIR}" 2>/dev/null || true
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y --no-install-recommends rclone age ca-certificates
|
||||
|
||||
- name: Find latest backup, validate freshness, download, decrypt, extract into Docker volume
|
||||
env:
|
||||
B2_KEY_ID: ${{ secrets.B2_KEY_ID }}
|
||||
B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }}
|
||||
AGE_PRIVATE_KEY: ${{ secrets.CASSANDRA_AGE_PRIVATE_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
rm -rf "$WORKDIR"
|
||||
mkdir -p "$WORKDIR"
|
||||
|
||||
export RCLONE_CONFIG_B2S3_TYPE=s3
|
||||
export RCLONE_CONFIG_B2S3_PROVIDER=Other
|
||||
export RCLONE_CONFIG_B2S3_ACCESS_KEY_ID="${B2_KEY_ID}"
|
||||
export RCLONE_CONFIG_B2S3_SECRET_ACCESS_KEY="${B2_APPLICATION_KEY}"
|
||||
export RCLONE_CONFIG_B2S3_ENDPOINT="https://s3.eu-central-003.backblazeb2.com"
|
||||
export RCLONE_CONFIG_B2S3_REGION="eu-central-003"
|
||||
export RCLONE_CONFIG_B2S3_FORCE_PATH_STYLE=true
|
||||
|
||||
LATEST_BACKUP="$(
|
||||
rclone lsf "B2S3:fluxer" --recursive --files-only --fast-list \
|
||||
| grep -E '(^|/)cassandra-backup-[0-9]{8}-[0-9]{6}\.tar\.age$' \
|
||||
| sort -r \
|
||||
| head -n 1
|
||||
)"
|
||||
|
||||
if [ -z "${LATEST_BACKUP}" ]; then
|
||||
echo "Error: No backup found in bucket"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "LATEST_BACKUP=${LATEST_BACKUP}" >> "$GITHUB_ENV"
|
||||
|
||||
base="$(basename "${LATEST_BACKUP}")"
|
||||
ts="${base#cassandra-backup-}"
|
||||
ts="${ts%.tar.age}"
|
||||
|
||||
if ! [[ "$ts" =~ ^[0-9]{8}-[0-9]{6}$ ]]; then
|
||||
echo "Error: Could not extract timestamp from backup filename: ${base}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKUP_EPOCH="$(date -u -d "${ts:0:8} ${ts:9:2}:${ts:11:2}:${ts:13:2}" +%s)"
|
||||
CURRENT_EPOCH="$(date -u +%s)"
|
||||
AGE_HOURS=$(( (CURRENT_EPOCH - BACKUP_EPOCH) / 3600 ))
|
||||
|
||||
echo "Backup age: ${AGE_HOURS} hours"
|
||||
if [ "${AGE_HOURS}" -ge 3 ]; then
|
||||
echo "Error: Latest backup is ${AGE_HOURS} hours old (threshold: 3 hours)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rclone copyto "B2S3:fluxer/${LATEST_BACKUP}" "${WORKDIR}/backup.tar.age" --fast-list
|
||||
|
||||
umask 077
|
||||
printf '%s' "${AGE_PRIVATE_KEY}" > "${WORKDIR}/age.key"
|
||||
|
||||
docker volume create "${BACKUP_VOLUME}"
|
||||
|
||||
age -d -i "${WORKDIR}/age.key" "${WORKDIR}/backup.tar.age" \
|
||||
| docker run --rm -i \
|
||||
-v "${BACKUP_VOLUME}:/backup" \
|
||||
--entrypoint bash \
|
||||
"${CASSANDRA_IMAGE}" -lc '
|
||||
set -euo pipefail
|
||||
rm -rf /backup/*
|
||||
mkdir -p /backup/_tmp
|
||||
tar -C /backup/_tmp -xf -
|
||||
|
||||
top="$(find /backup/_tmp -maxdepth 1 -mindepth 1 -type d -name "cassandra-backup-*" | head -n 1 || true)"
|
||||
|
||||
if [ -n "$top" ] && [ -f "$top/schema.cql" ]; then
|
||||
cp -a "$top"/. /backup/
|
||||
elif [ -f /backup/_tmp/schema.cql ]; then
|
||||
cp -a /backup/_tmp/. /backup/
|
||||
else
|
||||
echo "Error: schema.cql not found after extraction"
|
||||
find /backup/_tmp -maxdepth 3 -type f -print | sed -n "1,80p" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf /backup/_tmp
|
||||
'
|
||||
|
||||
docker run --rm \
|
||||
-v "${BACKUP_VOLUME}:/backup:ro" \
|
||||
--entrypoint bash \
|
||||
"${CASSANDRA_IMAGE}" -lc '
|
||||
set -euo pipefail
|
||||
test -f /backup/schema.cql
|
||||
echo "Extracted backup layout (top 3 levels):"
|
||||
find /backup -maxdepth 3 -type d -print | sed -n "1,200p" || true
|
||||
echo "Sample SSTables (*Data.db):"
|
||||
find /backup -type f -name "*Data.db" | sed -n "1,30p" || true
|
||||
'
|
||||
|
||||
- name: Create data volume
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker volume create "${CASS_VOLUME}"
|
||||
|
||||
- name: Restore keyspaces into volume and promote snapshot SSTables
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
docker run --rm \
|
||||
--name "${UTIL_CONTAINER}" \
|
||||
-v "${CASS_VOLUME}:/var/lib/cassandra" \
|
||||
-v "${BACKUP_VOLUME}:/backup:ro" \
|
||||
--entrypoint bash \
|
||||
"${CASSANDRA_IMAGE}" -lc '
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
BASE=/var/lib/cassandra
|
||||
DATA_DIR="$BASE/data"
|
||||
mkdir -p "$DATA_DIR" "$BASE/commitlog" "$BASE/hints" "$BASE/saved_caches"
|
||||
|
||||
ROOT=/backup
|
||||
if [ -d "$ROOT/cassandra_data" ]; then ROOT="$ROOT/cassandra_data"; fi
|
||||
if [ -d "$ROOT/data" ]; then ROOT="$ROOT/data"; fi
|
||||
|
||||
echo "Using backup ROOT=$ROOT"
|
||||
echo "Restoring into DATA_DIR=$DATA_DIR"
|
||||
|
||||
restored=0
|
||||
for keyspace_dir in "$ROOT"/*/; do
|
||||
[ -d "$keyspace_dir" ] || continue
|
||||
ks="$(basename "$keyspace_dir")"
|
||||
|
||||
if [ "$ks" = "system_schema" ] || ! [[ "$ks" =~ ^system ]]; then
|
||||
echo "Restoring keyspace: $ks"
|
||||
rm -rf "$DATA_DIR/$ks"
|
||||
cp -a "$keyspace_dir" "$DATA_DIR/"
|
||||
restored=$((restored + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$restored" -le 0 ]; then
|
||||
echo "Error: No keyspaces restored from backup root: $ROOT"
|
||||
echo "Debug: listing $ROOT:"
|
||||
ls -la "$ROOT" || true
|
||||
find "$ROOT" -maxdepth 2 -type d -print | sed -n "1,100p" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
promoted=0
|
||||
for ks_dir in "$DATA_DIR"/*/; do
|
||||
[ -d "$ks_dir" ] || continue
|
||||
ks="$(basename "$ks_dir")"
|
||||
|
||||
if [ "$ks" != "system_schema" ] && [[ "$ks" =~ ^system ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
for table_dir in "$ks_dir"*/; do
|
||||
[ -d "$table_dir" ] || continue
|
||||
|
||||
snap_root="$table_dir/snapshots"
|
||||
[ -d "$snap_root" ] || continue
|
||||
|
||||
latest_snap="$(ls -1d "$snap_root"/*/ 2>/dev/null | sort -r | head -n 1 || true)"
|
||||
[ -n "$latest_snap" ] || continue
|
||||
|
||||
files=( "$latest_snap"* )
|
||||
if [ "${#files[@]}" -gt 0 ]; then
|
||||
cp -av "${files[@]}" "$table_dir"
|
||||
promoted=$((promoted + $(ls -1 "$latest_snap"/*Data.db 2>/dev/null | wc -l || true)))
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
chown -R cassandra:cassandra "$BASE"
|
||||
|
||||
echo "Promoted Data.db files: $promoted"
|
||||
if [ "$promoted" -le 0 ]; then
|
||||
echo "Error: No *Data.db files were promoted out of snapshots"
|
||||
echo "Debug: first snapshot dirs found:"
|
||||
find "$DATA_DIR" -type d -path "*/snapshots/*" | sed -n "1,50p" || true
|
||||
exit 1
|
||||
fi
|
||||
'
|
||||
|
||||
- name: Start Cassandra
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
docker run -d \
|
||||
--name "${CASS_CONTAINER}" \
|
||||
-v "${CASS_VOLUME}:/var/lib/cassandra" \
|
||||
-e MAX_HEAP_SIZE="${MAX_HEAP_SIZE}" \
|
||||
-e HEAP_NEWSIZE="${HEAP_NEWSIZE}" \
|
||||
-e JVM_OPTS="-Dcassandra.disable_mlock=true" \
|
||||
"${CASSANDRA_IMAGE}"
|
||||
|
||||
for i in $(seq 1 150); do
|
||||
status="$(docker inspect -f '{{.State.Status}}' "${CASS_CONTAINER}" 2>/dev/null || true)"
|
||||
if [ "${status}" != "running" ]; then
|
||||
docker inspect "${CASS_CONTAINER}" --format 'ExitCode={{.State.ExitCode}} OOMKilled={{.State.OOMKilled}} Error={{.State.Error}}' || true
|
||||
docker logs --tail 300 "${CASS_CONTAINER}" || true
|
||||
exit 1
|
||||
fi
|
||||
if docker exec "${CASS_CONTAINER}" cqlsh -e "SELECT now() FROM system.local;" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
docker exec "${CASS_CONTAINER}" cqlsh -e "SELECT now() FROM system.local;" >/dev/null 2>&1
|
||||
|
||||
- name: Verify data
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
USER_COUNT=""
|
||||
for i in $(seq 1 20); do
|
||||
USER_COUNT="$(
|
||||
docker exec "${CASS_CONTAINER}" cqlsh -e "SELECT COUNT(*) FROM fluxer.users;" 2>/dev/null \
|
||||
| awk "/^[[:space:]]*[0-9]+[[:space:]]*$/ {print \$1; exit}" || true
|
||||
)"
|
||||
if [ -n "${USER_COUNT}" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ -n "${USER_COUNT}" ] && [ "${USER_COUNT}" -gt 0 ] 2>/dev/null; then
|
||||
echo "Backup restore verification passed"
|
||||
else
|
||||
echo "Backup restore verification failed"
|
||||
docker logs --tail 300 "${CASS_CONTAINER}" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker rm -f "${CASS_CONTAINER}" 2>/dev/null || true
|
||||
docker volume rm "${CASS_VOLUME}" 2>/dev/null || true
|
||||
docker volume rm "${BACKUP_VOLUME}" 2>/dev/null || true
|
||||
rm -rf "${WORKDIR}" 2>/dev/null || true
|
||||
|
||||
- name: Report status
|
||||
if: always()
|
||||
run: |
|
||||
set -euo pipefail
|
||||
LATEST_BACKUP_NAME="${LATEST_BACKUP:-unknown}"
|
||||
if [ "${{ job.status }}" = "success" ]; then
|
||||
echo "Backup ${LATEST_BACKUP_NAME} is valid and restorable"
|
||||
else
|
||||
echo "Backup ${LATEST_BACKUP_NAME} test failed"
|
||||
fi
|
||||
73
.github/workflows/update-word-lists.yaml
vendored
Normal file
73
.github/workflows/update-word-lists.yaml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
name: update word-lists
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 1 * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update-word-lists:
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: canary
|
||||
|
||||
- name: Download latest word lists
|
||||
run: |
|
||||
set -euo pipefail
|
||||
curl -fsSL https://raw.githubusercontent.com/tailscale/tailscale/refs/heads/main/words/scales.txt -o /tmp/scales.txt
|
||||
curl -fsSL https://raw.githubusercontent.com/tailscale/tailscale/refs/heads/main/words/tails.txt -o /tmp/tails.txt
|
||||
|
||||
- name: Check for changes
|
||||
id: check_changes
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Compare the downloaded files with the existing ones
|
||||
if ! diff -q /tmp/scales.txt fluxer_api/src/words/scales.txt > /dev/null 2>&1 || \
|
||||
! diff -q /tmp/tails.txt fluxer_api/src/words/tails.txt > /dev/null 2>&1; then
|
||||
printf 'changes_detected=true\n' >> "$GITHUB_OUTPUT"
|
||||
echo "Changes detected in word lists"
|
||||
else
|
||||
printf 'changes_detected=false\n' >> "$GITHUB_OUTPUT"
|
||||
echo "No changes detected in word lists"
|
||||
fi
|
||||
|
||||
- name: Update word lists
|
||||
if: steps.check_changes.outputs.changes_detected == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cp /tmp/scales.txt fluxer_api/src/words/scales.txt
|
||||
cp /tmp/tails.txt fluxer_api/src/words/tails.txt
|
||||
|
||||
- name: Create pull request for updated word lists
|
||||
if: steps.check_changes.outputs.changes_detected == 'true'
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: word-lists-update-${{ github.run_id }}
|
||||
base: canary
|
||||
title: 'chore: update word lists from Tailscale upstream'
|
||||
body: |
|
||||
Automated update of scales.txt and tails.txt from the Tailscale repository.
|
||||
|
||||
These files are used to generate connection IDs for voice connections.
|
||||
|
||||
Source:
|
||||
- https://github.com/tailscale/tailscale/blob/main/words/scales.txt
|
||||
- https://github.com/tailscale/tailscale/blob/main/words/tails.txt
|
||||
commit-message: 'chore: update word lists from Tailscale upstream'
|
||||
files: |
|
||||
fluxer_api/src/words/scales.txt
|
||||
fluxer_api/src/words/tails.txt
|
||||
labels: automation
|
||||
|
||||
- name: No changes detected
|
||||
if: steps.check_changes.outputs.changes_detected == 'false'
|
||||
run: echo "Word lists are already up to date."
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -34,7 +34,6 @@
|
||||
**/fluxer.env
|
||||
**/secrets.env
|
||||
/dev/fluxer.env
|
||||
/dev/secret.txt
|
||||
|
||||
# Logs, temporary files, and binaries
|
||||
**/*.beam
|
||||
|
||||
85
.ignore
Normal file
85
.ignore
Normal file
@@ -0,0 +1,85 @@
|
||||
# Build artifact directories
|
||||
**/_build
|
||||
**/_checkouts
|
||||
**/_vendor
|
||||
**/.astro/
|
||||
**/build
|
||||
!fluxer_app/scripts/build
|
||||
**/coverage
|
||||
**/dist
|
||||
fluxer_app/dist/
|
||||
**/generated
|
||||
**/target
|
||||
**/ebin
|
||||
**/certificates
|
||||
|
||||
# Dependency directories
|
||||
**/node_modules
|
||||
**/.pnpm-store
|
||||
|
||||
# Framework & tooling buckets
|
||||
**/.next
|
||||
**/.next/cache
|
||||
**/.vercel
|
||||
**/out
|
||||
**/.pnp
|
||||
**/.pnp.js
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# Cache directories
|
||||
**/.cache
|
||||
**/.*cache
|
||||
**/.swc
|
||||
|
||||
# Logs and temporary files
|
||||
**/*.beam
|
||||
**/*.dump
|
||||
**/*.iml
|
||||
**/*.log
|
||||
**/*.o
|
||||
**/*.plt
|
||||
**/*.swo
|
||||
**/*.swp
|
||||
**/*.tmp
|
||||
**/*~
|
||||
**/*.lock
|
||||
**/log
|
||||
**/logs
|
||||
**/npm-debug.log*
|
||||
**/pnpm-debug.log*
|
||||
**/yarn-debug.log*
|
||||
**/yarn-error.log*
|
||||
**/rebar3.crashdump
|
||||
**/erl_crash.dump
|
||||
|
||||
# Source files we never want tracked
|
||||
**/.source
|
||||
**/*.source
|
||||
|
||||
# Environment files
|
||||
**/.env
|
||||
**/.env.local
|
||||
**/.env.*.local
|
||||
**/.dev.vars
|
||||
**/.erlang.cookie
|
||||
**/.eunit
|
||||
**/.rebar
|
||||
**/.rebar3
|
||||
**/fluxer.env
|
||||
**/secrets.env
|
||||
/dev/fluxer.env
|
||||
|
||||
# Project-specific artifacts
|
||||
/fluxer_app/src/assets/emoji-sprites/
|
||||
/fluxer_app/src/locales/*/messages.js
|
||||
/fluxer_admin/priv/static/app.css
|
||||
/fluxer_marketing/priv/static/app.css
|
||||
app.css
|
||||
fluxer_static
|
||||
geoip_data
|
||||
livekit.yaml
|
||||
fluxer.yaml
|
||||
|
||||
# Generated CSS type definitions
|
||||
**/*.css.d.ts
|
||||
2
.lfsconfig
Normal file
2
.lfsconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
[lfs]
|
||||
url = https://github.com/fluxerapp/fluxer.git/info/lfs
|
||||
25
.prettierignore
Normal file
25
.prettierignore
Normal file
@@ -0,0 +1,25 @@
|
||||
node_modules
|
||||
**/node_modules
|
||||
**/.cache
|
||||
**/.pnpm-store
|
||||
**/.swc
|
||||
fluxer_app/dist
|
||||
fluxer_app/src/assets/emoji-sprites
|
||||
fluxer_app/src/locales/*/messages.js
|
||||
fluxer_app/pkgs/libfluxcore
|
||||
fluxer_app/pkgs/libfluxcore/**
|
||||
fluxer_app/proxy/assets
|
||||
fluxer_gateway/_build
|
||||
fluxer_marketing/build
|
||||
fluxer_docs/.next
|
||||
fluxer_docs/.next/cache
|
||||
fluxer_docs/out
|
||||
fluxer_docs/.vercel
|
||||
fluxer_docs/.cache
|
||||
fluxer_docs/coverage
|
||||
fluxer_static/**
|
||||
dev/geoip_data
|
||||
dev/livekit.yaml
|
||||
dev/fluxer.yaml
|
||||
*.log
|
||||
**/*.css.d.ts
|
||||
92
CODE_OF_CONDUCT.md
Normal file
92
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
- demonstrating empathy and kindness toward other people
|
||||
- being respectful of differing opinions, viewpoints, and experiences
|
||||
- giving and gracefully accepting constructive feedback
|
||||
- accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
- focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- the use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||
- trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- public or private harassment
|
||||
- publishing others' private information, such as a physical or email address, without their explicit permission
|
||||
- other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
## Reporting
|
||||
|
||||
If you experience or witness unacceptable behavior, please report it as soon as possible.
|
||||
|
||||
How to report:
|
||||
|
||||
- Email the maintainers at: developers@fluxer.app
|
||||
- If your report involves someone who may have access to that inbox, you can instead contact a maintainer privately on GitHub.
|
||||
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1) Correction
|
||||
|
||||
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2) Warning
|
||||
|
||||
Community Impact: A violation through a single incident or series of actions.
|
||||
|
||||
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
### 3) Temporary Ban
|
||||
|
||||
Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4) Permanent Ban
|
||||
|
||||
Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
Consequence: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at:
|
||||
|
||||
- https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
|
||||
Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ:
|
||||
|
||||
- https://www.contributor-covenant.org/faq
|
||||
|
||||
Translations are available at:
|
||||
|
||||
- https://www.contributor-covenant.org/translations
|
||||
163
CONTRIBUTING.md
Normal file
163
CONTRIBUTING.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# Contributing to fluxerapp/fluxer
|
||||
|
||||
Thanks for contributing. This document explains how we work so your changes can land smoothly, and so nobody wastes time on work we cannot merge.
|
||||
|
||||
## Quick rules (please read)
|
||||
|
||||
### 1) All PRs must target `canary`
|
||||
|
||||
`canary` is our trunk branch. Open all pull requests against `canary`. PRs targeting other branches will be closed or you will be asked to retarget.
|
||||
|
||||
### 2) All PRs must include a short description
|
||||
|
||||
Every PR must include a short description covering:
|
||||
|
||||
- what changed
|
||||
- why it changed
|
||||
- anything reviewers should pay attention to
|
||||
|
||||
A few bullets is perfect.
|
||||
|
||||
### 3) Coordinate before starting larger work
|
||||
|
||||
If you are planning anything beyond a small, obvious fix (new feature, meaningful refactor, new dependency, new API surface, behavior changes), coordinate with the maintainers first.
|
||||
|
||||
This avoids the mutual displeasure of:
|
||||
|
||||
- you investing significant time, and
|
||||
- us having to reject or postpone the change because it does not align with current goals, or because we are not ready to maintain what it introduces
|
||||
|
||||
Ways to coordinate:
|
||||
|
||||
- open an issue describing the problem and your proposed approach
|
||||
- open a draft PR early to confirm direction
|
||||
- discuss with a maintainer in any channel you already share
|
||||
|
||||
If you are unsure whether something counts as "larger work", ask first.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Fork the repo (or create a branch if you have access).
|
||||
2. Create a feature branch from `canary`.
|
||||
3. Make changes.
|
||||
4. Open a PR into `canary` with a short description.
|
||||
5. Address review feedback and CI results.
|
||||
6. We squash-merge approved PRs into `canary`.
|
||||
|
||||
We strongly prefer small, focused PRs that are easy to review.
|
||||
|
||||
### Commit style and history
|
||||
|
||||
We squash-merge PRs, and the PR title becomes the single commit message on `canary`. For that reason:
|
||||
|
||||
- PR titles must follow Conventional Commits.
|
||||
- Individual commits inside the PR do not need to follow Conventional Commits.
|
||||
|
||||
If you like to commit in small increments, feel free. If you prefer a tidier PR history, force-pushes are welcome (for example, to squash or reorder commits before review). Just avoid rewriting history in a way that makes it hard for reviewers to follow along.
|
||||
|
||||
## Conventional Commits (required for PR titles)
|
||||
|
||||
Because the PR title becomes the squash commit message, we require Conventional Commits for PR titles.
|
||||
|
||||
We prefer type/subject to be mostly lowercase.
|
||||
|
||||
Format:
|
||||
|
||||
- `type(scope optional): short description`
|
||||
|
||||
Examples:
|
||||
|
||||
- `fix: handle empty response from api`
|
||||
- `feat(auth): add passkey login`
|
||||
- `docs: clarify canary workflow`
|
||||
- `refactor: simplify retry logic`
|
||||
- `chore(ci): speed up checks`
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- `feat!: remove legacy auth endpoints`
|
||||
- `refactor(api)!: change pagination shape`
|
||||
|
||||
Common types:
|
||||
`feat`, `fix`, `docs`, `refactor`, `perf`, `test`, `chore`, `ci`, `build`, `revert`
|
||||
|
||||
## Tests (guidance)
|
||||
|
||||
We care about confidence more than ceremony. Add tests when they provide real value.
|
||||
|
||||
### Backend changes
|
||||
|
||||
For backend changes, we suggest adding an integration or unit test.
|
||||
|
||||
- If a unit test would require heavy mocking to be meaningful, either:
|
||||
- restructure the code so it can be tested without excessive mocking, or
|
||||
- prefer an integration test if restructuring is not practical
|
||||
|
||||
- If you are unsure which route is best, discuss it with a maintainer before investing time.
|
||||
|
||||
### Frontend changes
|
||||
|
||||
We generally do not encourage new unit tests for frontend code unless:
|
||||
|
||||
- the area already has unit tests, or
|
||||
- the change is complex or sensitive, and a unit test clearly reduces risk
|
||||
|
||||
In most cases, clear PR notes and practical verification are more valuable.
|
||||
|
||||
## Formatting and linting
|
||||
|
||||
Do not block on formatting or linting before opening a PR. CI enforces required checks and will tell you what needs fixing before merge.
|
||||
|
||||
Open the PR when it is ready for review, then iterate based on CI and feedback.
|
||||
|
||||
## CLA (required)
|
||||
|
||||
We require a Contributor License Agreement (CLA) for this repository.
|
||||
|
||||
Why:
|
||||
|
||||
- The project is available under AGPLv3.
|
||||
- We also offer a commercial license for organizations that cannot (or do not want to) comply with AGPL obligations.
|
||||
- To keep both options possible, we need permission to include contributions in both distributions.
|
||||
|
||||
What it means for you:
|
||||
|
||||
- You keep ownership of your contribution.
|
||||
- You can keep using your contribution in your own work.
|
||||
- You grant us the rights needed to distribute your contribution as part of the project, including under a commercial license.
|
||||
- We may refactor or remove code over time and are not required to include every contribution. However, any distributed version that includes your contribution remains properly licensed under the project license(s) that applied when you contributed.
|
||||
|
||||
How to sign:
|
||||
|
||||
- On your first PR, a bot will comment with a CLA link.
|
||||
- Click it, sign with your GitHub account, and you are done.
|
||||
|
||||
## PR checklist
|
||||
|
||||
Before requesting review:
|
||||
|
||||
- [ ] PR targets `canary`
|
||||
- [ ] PR title follows Conventional Commits (mostly lowercase)
|
||||
- [ ] PR includes a short description of what/why
|
||||
- [ ] Tests added or updated where it makes sense (especially backend changes)
|
||||
- [ ] CI is green (or you are actively addressing failures)
|
||||
- [ ] CLA signed (the bot will guide you)
|
||||
|
||||
Optional but helpful:
|
||||
|
||||
- screenshots or a short recording for UI changes
|
||||
- manual verification steps
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project follows a Code of Conduct. By participating, you are expected to uphold it:
|
||||
|
||||
- See [`CODE_OF_CONDUCT.md`](./CODE_OF_CONDUCT.md)
|
||||
|
||||
## Security
|
||||
|
||||
Please do not report security issues via public GitHub issues.
|
||||
|
||||
Use our security policy and reporting instructions here:
|
||||
|
||||
- https://fluxer.app/security
|
||||
661
LICENSE
Normal file
661
LICENSE
Normal file
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
20
README.md
20
README.md
@@ -1,2 +1,20 @@
|
||||
# fx-test
|
||||
<div align="left" style="margin:12px 0 8px;">
|
||||
<img src="./media/logo-graphic.png" alt="Fluxer graphic logo" width="360">
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
Fluxer is an open-source, independent instant messaging and VoIP platform. Built for friends, groups, and communities.
|
||||
|
||||
<div align="left" style="margin:16px 0 0; width:100%;">
|
||||
<img
|
||||
src="./media/app-showcase.png"
|
||||
alt="Fluxer app showcase"
|
||||
style="display:block; width:100%; max-width:1200px; box-sizing:border-box;"
|
||||
>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
> [!NOTE]
|
||||
> Docs are coming very soon! With your help and [donations](https://fluxer.app/donate), the self-hosting and documentation story will get a lot better.
|
||||
|
||||
5
SECURITY.md
Normal file
5
SECURITY.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Security Policy
|
||||
|
||||
Please **do not** report security vulnerabilities via public GitHub issues.
|
||||
|
||||
Report security issues here: https://fluxer.app/security
|
||||
139
biome.json
Normal file
139
biome.json
Normal file
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"formatWithErrors": false,
|
||||
"indentStyle": "tab",
|
||||
"lineWidth": 120,
|
||||
"lineEnding": "lf",
|
||||
"bracketSpacing": false
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "single",
|
||||
"jsxQuoteStyle": "double",
|
||||
"quoteProperties": "asNeeded",
|
||||
"trailingCommas": "all",
|
||||
"semicolons": "always",
|
||||
"arrowParentheses": "always",
|
||||
"bracketSpacing": false,
|
||||
"bracketSameLine": false
|
||||
},
|
||||
"globals": ["React"]
|
||||
},
|
||||
"json": {
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "tab",
|
||||
"lineWidth": 120
|
||||
},
|
||||
"parser": {
|
||||
"allowComments": true,
|
||||
"allowTrailingCommas": true
|
||||
}
|
||||
},
|
||||
"css": {
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "tab",
|
||||
"lineWidth": 120,
|
||||
"quoteStyle": "single"
|
||||
},
|
||||
"parser": {
|
||||
"cssModules": true
|
||||
}
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"complexity": {
|
||||
"noForEach": "off",
|
||||
"noImportantStyles": "off"
|
||||
},
|
||||
"correctness": {
|
||||
"noUndeclaredVariables": "error",
|
||||
"noUnusedVariables": "error",
|
||||
"noInvalidUseBeforeDeclaration": "off",
|
||||
"useExhaustiveDependencies": "off"
|
||||
},
|
||||
"suspicious": {
|
||||
"noArrayIndexKey": "off",
|
||||
"noAssignInExpressions": "off",
|
||||
"noExplicitAny": "off",
|
||||
"noDoubleEquals": {
|
||||
"level": "error",
|
||||
"options": {
|
||||
"ignoreNull": true
|
||||
}
|
||||
},
|
||||
"noVar": "error",
|
||||
"useAdjacentOverloadSignatures": "off",
|
||||
"useIterableCallbackReturn": "off"
|
||||
},
|
||||
"style": {
|
||||
"useConsistentArrayType": {
|
||||
"level": "error",
|
||||
"options": {
|
||||
"syntax": "generic"
|
||||
}
|
||||
},
|
||||
"useConst": "error",
|
||||
"noNonNullAssertion": "off",
|
||||
"noParameterAssign": "off"
|
||||
},
|
||||
"a11y": {
|
||||
"recommended": true,
|
||||
"useAriaPropsForRole": "error",
|
||||
"useValidAriaRole": "error",
|
||||
"useValidAriaValues": "error",
|
||||
"useValidAriaProps": "error",
|
||||
"useAltText": "error",
|
||||
"useAnchorContent": "error",
|
||||
"useButtonType": "error",
|
||||
"useKeyWithClickEvents": "error",
|
||||
"useKeyWithMouseEvents": "error",
|
||||
"useSemanticElements": "off",
|
||||
"noAriaUnsupportedElements": "error",
|
||||
"noNoninteractiveElementToInteractiveRole": "error",
|
||||
"noNoninteractiveTabindex": "error",
|
||||
"noRedundantAlt": "error",
|
||||
"noRedundantRoles": "error",
|
||||
"noInteractiveElementToNoninteractiveRole": "error",
|
||||
"noAutofocus": "warn",
|
||||
"noAccessKey": "warn",
|
||||
"useAriaActivedescendantWithTabindex": "error",
|
||||
"noSvgWithoutTitle": "warn"
|
||||
},
|
||||
"nursery": {
|
||||
"useSortedClasses": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assist": {"actions": {"source": {"organizeImports": "on"}}},
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": {
|
||||
"includes": [
|
||||
"**",
|
||||
"!**/.git",
|
||||
"!**/app.css",
|
||||
"!**/build",
|
||||
"fluxer_app/scripts/build",
|
||||
"!**/dist",
|
||||
"!**/fluxer_app/src/data/emojis.json",
|
||||
"!**/fluxer_app/src/locales/*/messages.js",
|
||||
"!**/fluxer_app/src/env.d.ts",
|
||||
"!**/node_modules",
|
||||
"!**/tailwind.css",
|
||||
"!**/*.html",
|
||||
"!**/*.module.css.d.ts",
|
||||
"!**/fluxer_app/src/components/uikit/SVGMasks.tsx",
|
||||
"!fluxer_static"
|
||||
],
|
||||
"ignoreUnknown": true
|
||||
}
|
||||
}
|
||||
166
dev/.env.example
Normal file
166
dev/.env.example
Normal file
@@ -0,0 +1,166 @@
|
||||
NODE_ENV=development
|
||||
|
||||
FLUXER_API_PUBLIC_ENDPOINT=http://127.0.0.1:8088/api
|
||||
FLUXER_API_CLIENT_ENDPOINT=
|
||||
FLUXER_APP_ENDPOINT=http://localhost:8088
|
||||
FLUXER_GATEWAY_ENDPOINT=ws://127.0.0.1:8088/gateway
|
||||
FLUXER_MEDIA_ENDPOINT=http://127.0.0.1:8088/media
|
||||
FLUXER_CDN_ENDPOINT=https://fluxerstatic.com
|
||||
FLUXER_MARKETING_ENDPOINT=http://127.0.0.1:8088
|
||||
FLUXER_ADMIN_ENDPOINT=http://127.0.0.1:8088
|
||||
FLUXER_INVITE_ENDPOINT=http://fluxer.gg
|
||||
FLUXER_GIFT_ENDPOINT=http://fluxer.gift
|
||||
FLUXER_API_HOST=api:8080
|
||||
|
||||
FLUXER_API_PORT=8080
|
||||
FLUXER_GATEWAY_WS_PORT=8080
|
||||
FLUXER_GATEWAY_RPC_PORT=8081
|
||||
FLUXER_MEDIA_PROXY_PORT=8080
|
||||
FLUXER_ADMIN_PORT=8080
|
||||
FLUXER_MARKETING_PORT=8080
|
||||
|
||||
FLUXER_PATH_GATEWAY=/gateway
|
||||
FLUXER_PATH_ADMIN=/admin
|
||||
FLUXER_PATH_MARKETING=/marketing
|
||||
|
||||
API_HOST=api:8080
|
||||
FLUXER_GATEWAY_RPC_HOST=
|
||||
FLUXER_GATEWAY_PUSH_ENABLED=false
|
||||
FLUXER_GATEWAY_PUSH_USER_GUILD_SETTINGS_CACHE_MB=1024
|
||||
FLUXER_GATEWAY_PUSH_SUBSCRIPTIONS_CACHE_MB=1024
|
||||
FLUXER_GATEWAY_PUSH_BLOCKED_IDS_CACHE_MB=1024
|
||||
FLUXER_GATEWAY_IDENTIFY_RATE_LIMIT_ENABLED=false
|
||||
|
||||
FLUXER_MEDIA_PROXY_HOST=
|
||||
MEDIA_PROXY_ENDPOINT=
|
||||
|
||||
VAPID_PUBLIC_KEY=
|
||||
VAPID_PRIVATE_KEY=
|
||||
VAPID_EMAIL=support@fluxer.app
|
||||
|
||||
SUDO_MODE_SECRET=
|
||||
PASSKEYS_ENABLED=true
|
||||
PASSKEY_RP_NAME=Fluxer
|
||||
PASSKEY_RP_ID=127.0.0.1
|
||||
PASSKEY_ALLOWED_ORIGINS=http://127.0.0.1:8088,http://localhost:8088
|
||||
|
||||
ADMIN_OAUTH2_CLIENT_ID=
|
||||
ADMIN_OAUTH2_CLIENT_SECRET=
|
||||
ADMIN_OAUTH2_AUTO_CREATE=false
|
||||
ADMIN_OAUTH2_REDIRECT_URI=http://127.0.0.1:8088/admin/oauth2_callback
|
||||
|
||||
RELEASE_CHANNEL=stable
|
||||
|
||||
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/fluxer
|
||||
|
||||
REDIS_URL=redis://redis:6379
|
||||
|
||||
CASSANDRA_HOSTS=cassandra
|
||||
CASSANDRA_KEYSPACE=fluxer
|
||||
CASSANDRA_LOCAL_DC=datacenter1
|
||||
CASSANDRA_USERNAME=cassandra
|
||||
CASSANDRA_PASSWORD=cassandra
|
||||
|
||||
AWS_S3_ENDPOINT=http://minio:9000
|
||||
AWS_ACCESS_KEY_ID=minioadmin
|
||||
AWS_SECRET_ACCESS_KEY=minioadmin
|
||||
|
||||
AWS_S3_BUCKET_CDN=fluxer
|
||||
AWS_S3_BUCKET_UPLOADS=fluxer-uploads
|
||||
AWS_S3_BUCKET_DOWNLOADS=fluxer-downloads
|
||||
AWS_S3_BUCKET_REPORTS=fluxer-reports
|
||||
AWS_S3_BUCKET_HARVESTS=fluxer-harvests
|
||||
|
||||
R2_S3_ENDPOINT=http://minio:9000
|
||||
R2_ACCESS_KEY_ID=minioadmin
|
||||
R2_SECRET_ACCESS_KEY=minioadmin
|
||||
|
||||
METRICS_MODE=noop
|
||||
|
||||
CLICKHOUSE_URL=http://clickhouse:8123
|
||||
CLICKHOUSE_DATABASE=fluxer_metrics
|
||||
CLICKHOUSE_USER=fluxer
|
||||
CLICKHOUSE_PASSWORD=fluxer_dev
|
||||
|
||||
ANOMALY_DETECTION_ENABLED=true
|
||||
ANOMALY_WINDOW_SIZE=100
|
||||
ANOMALY_ZSCORE_THRESHOLD=3.0
|
||||
ANOMALY_CHECK_INTERVAL_SECS=60
|
||||
ANOMALY_COOLDOWN_SECS=300
|
||||
ANOMALY_ERROR_RATE_THRESHOLD=0.05
|
||||
ALERT_WEBHOOK_URL=
|
||||
|
||||
EMAIL_ENABLED=false
|
||||
SENDGRID_FROM_EMAIL=noreply@fluxer.app
|
||||
SENDGRID_FROM_NAME=Fluxer
|
||||
SENDGRID_API_KEY=
|
||||
SENDGRID_WEBHOOK_PUBLIC_KEY=
|
||||
|
||||
SMS_ENABLED=false
|
||||
TWILIO_ACCOUNT_SID=
|
||||
TWILIO_AUTH_TOKEN=
|
||||
TWILIO_VERIFY_SERVICE_SID=
|
||||
|
||||
CAPTCHA_ENABLED=true
|
||||
CAPTCHA_PRIMARY_PROVIDER=turnstile
|
||||
|
||||
HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001
|
||||
HCAPTCHA_PUBLIC_SITE_KEY=10000000-ffff-ffff-ffff-000000000001
|
||||
HCAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000
|
||||
|
||||
TURNSTILE_SITE_KEY=1x00000000000000000000AA
|
||||
TURNSTILE_PUBLIC_SITE_KEY=1x00000000000000000000AA
|
||||
TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA
|
||||
|
||||
SEARCH_ENABLED=true
|
||||
MEILISEARCH_URL=http://meilisearch:7700
|
||||
MEILISEARCH_API_KEY=masterKey
|
||||
|
||||
STRIPE_ENABLED=false
|
||||
STRIPE_SECRET_KEY=
|
||||
STRIPE_WEBHOOK_SECRET=
|
||||
|
||||
STRIPE_PRICE_ID_MONTHLY_USD=
|
||||
STRIPE_PRICE_ID_MONTHLY_EUR=
|
||||
STRIPE_PRICE_ID_YEARLY_USD=
|
||||
STRIPE_PRICE_ID_YEARLY_EUR=
|
||||
STRIPE_PRICE_ID_VISIONARY_USD=
|
||||
STRIPE_PRICE_ID_VISIONARY_EUR=
|
||||
STRIPE_PRICE_ID_GIFT_VISIONARY_USD=
|
||||
STRIPE_PRICE_ID_GIFT_VISIONARY_EUR=
|
||||
STRIPE_PRICE_ID_GIFT_1_MONTH_USD=
|
||||
STRIPE_PRICE_ID_GIFT_1_MONTH_EUR=
|
||||
STRIPE_PRICE_ID_GIFT_1_YEAR_USD=
|
||||
STRIPE_PRICE_ID_GIFT_1_YEAR_EUR=
|
||||
|
||||
CLOUDFLARE_PURGE_ENABLED=false
|
||||
CLOUDFLARE_ZONE_ID=
|
||||
CLOUDFLARE_API_TOKEN=
|
||||
CLOUDFLARE_TUNNEL_TOKEN=
|
||||
|
||||
VOICE_ENABLED=true
|
||||
LIVEKIT_API_KEY=
|
||||
LIVEKIT_API_SECRET=
|
||||
LIVEKIT_WEBHOOK_URL=http://api:8080/webhooks/livekit
|
||||
LIVEKIT_AUTO_CREATE_DUMMY_DATA=true
|
||||
|
||||
CLAMAV_ENABLED=false
|
||||
CLAMAV_HOST=clamav
|
||||
CLAMAV_PORT=3310
|
||||
|
||||
TENOR_API_KEY=
|
||||
YOUTUBE_API_KEY=
|
||||
|
||||
SECRET_KEY_BASE=
|
||||
GATEWAY_RPC_SECRET=
|
||||
GATEWAY_ADMIN_SECRET=
|
||||
ERLANG_COOKIE=fluxer_dev_cookie
|
||||
MEDIA_PROXY_SECRET_KEY=
|
||||
|
||||
SELF_HOSTED=false
|
||||
AUTO_JOIN_INVITE_CODE=
|
||||
FLUXER_VISIONARIES_GUILD_ID=
|
||||
FLUXER_OPERATORS_GUILD_ID=
|
||||
|
||||
GIT_SHA=dev
|
||||
BUILD_TIMESTAMP=
|
||||
@@ -1,91 +1,59 @@
|
||||
:8088 {
|
||||
encode zstd gzip
|
||||
|
||||
# Security headers
|
||||
header {
|
||||
# HSTS
|
||||
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
||||
# Prevent clickjacking
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
# XSS protection
|
||||
X-Content-Type-Options "nosniff"
|
||||
# Referrer policy
|
||||
Referrer-Policy "strict-origin-when-cross-origin"
|
||||
# Remove server info
|
||||
-Server
|
||||
}
|
||||
|
||||
@api path /api/*
|
||||
handle @api {
|
||||
handle_path /api/* {
|
||||
reverse_proxy api:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy api:8080
|
||||
}
|
||||
}
|
||||
|
||||
@media path /media/*
|
||||
handle @media {
|
||||
handle_path /media/* {
|
||||
reverse_proxy media:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy media:8080
|
||||
}
|
||||
}
|
||||
|
||||
@s3 path /s3/*
|
||||
handle @s3 {
|
||||
handle_path /s3/* {
|
||||
reverse_proxy minio:9000 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy minio:9000
|
||||
}
|
||||
}
|
||||
|
||||
@admin path /admin /admin/*
|
||||
handle @admin {
|
||||
uri strip_prefix /admin
|
||||
reverse_proxy admin:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy admin:8080
|
||||
}
|
||||
|
||||
@marketing path /marketing /marketing/*
|
||||
handle @marketing {
|
||||
uri strip_prefix /marketing
|
||||
reverse_proxy marketing:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy marketing:8080
|
||||
}
|
||||
|
||||
@gateway path /gateway /gateway/*
|
||||
handle @gateway {
|
||||
uri strip_prefix /gateway
|
||||
reverse_proxy gateway:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy gateway:8080
|
||||
}
|
||||
|
||||
@livekit path /livekit /livekit/*
|
||||
handle @livekit {
|
||||
handle_path /livekit/* {
|
||||
reverse_proxy livekit:7880 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy livekit:7880
|
||||
}
|
||||
}
|
||||
|
||||
@metrics path /metrics /metrics/*
|
||||
handle @metrics {
|
||||
uri strip_prefix /metrics
|
||||
reverse_proxy metrics:8080 {
|
||||
header_up X-Forwarded-For {remote}
|
||||
}
|
||||
reverse_proxy metrics:8080
|
||||
}
|
||||
|
||||
handle {
|
||||
root * /app/dist
|
||||
try_files {path} /index.html
|
||||
file_server
|
||||
reverse_proxy host.docker.internal:3000
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ services:
|
||||
- PORT=8080
|
||||
- APP_MODE=admin
|
||||
- FLUXER_METRICS_HOST=metrics:8080
|
||||
- FLUXER_API_PUBLIC_ENDPOINT=http://api:8080
|
||||
volumes:
|
||||
- admin_build:/workspace/build
|
||||
networks:
|
||||
|
||||
@@ -22,12 +22,12 @@ import type {RouteRateLimitConfig} from '~/middleware/RateLimitMiddleware';
|
||||
export const AuthRateLimitConfigs = {
|
||||
AUTH_REGISTER: {
|
||||
bucket: 'auth:register',
|
||||
config: {limit: 50, windowMs: 60000},
|
||||
config: {limit: 10, windowMs: 10000},
|
||||
} as RouteRateLimitConfig,
|
||||
|
||||
AUTH_LOGIN: {
|
||||
bucket: 'auth:login',
|
||||
config: {limit: 50, windowMs: 60000},
|
||||
config: {limit: 10, windowMs: 10000},
|
||||
} as RouteRateLimitConfig,
|
||||
|
||||
AUTH_LOGIN_MFA: {
|
||||
|
||||
@@ -33,7 +33,7 @@ const DIST_DIR = path.join(ROOT_DIR, 'dist');
|
||||
const PKGS_DIR = path.join(ROOT_DIR, 'pkgs');
|
||||
const PUBLIC_DIR = path.join(ROOT_DIR, 'assets');
|
||||
|
||||
const CDN_ENDPOINT = process.env.CDN_ENDPOINT || '';
|
||||
const CDN_ENDPOINT = 'https://fluxerstatic.com';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const isDevelopment = !isProduction;
|
||||
|
||||
90
go.mod
Normal file
90
go.mod
Normal file
@@ -0,0 +1,90 @@
|
||||
module fluxer.dev
|
||||
|
||||
go 1.25.5
|
||||
|
||||
require (
|
||||
github.com/go-webauthn/webauthn v0.15.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/klauspost/compress v1.18.0
|
||||
github.com/livekit/server-sdk-go/v2 v2.12.8
|
||||
github.com/pion/webrtc/v4 v4.1.6
|
||||
github.com/redis/go-redis/v9 v9.14.0
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/stripe/stripe-go/v79 v79.4.0
|
||||
golang.org/x/text v0.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 // indirect
|
||||
buf.build/go/protovalidate v1.0.0 // indirect
|
||||
buf.build/go/protoyaml v0.6.0 // indirect
|
||||
cel.dev/expr v0.24.0 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||
github.com/benbjohnson/clock v1.3.5 // indirect
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dennwc/iters v1.2.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/frostbyte73/core v0.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
|
||||
github.com/gammazero/deque v1.1.0 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.4 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/google/cel-go v0.26.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jxskiss/base62 v1.1.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/lithammer/shortuuid/v4 v4.2.0 // indirect
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 // indirect
|
||||
github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade // indirect
|
||||
github.com/livekit/protocol v1.42.3-0.20251023002554-070839e4cae7 // indirect
|
||||
github.com/livekit/psrpc v0.7.0 // indirect
|
||||
github.com/magefile/mage v1.15.0 // indirect
|
||||
github.com/moby/sys/user v0.4.0 // indirect
|
||||
github.com/nats-io/nats.go v1.47.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.11 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.7 // indirect
|
||||
github.com/pion/ice/v4 v4.0.10 // indirect
|
||||
github.com/pion/interceptor v0.1.41 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.15 // indirect
|
||||
github.com/pion/rtp v1.8.23 // indirect
|
||||
github.com/pion/sctp v1.8.40 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.16 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.8 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.8 // indirect
|
||||
github.com/pion/turn/v4 v4.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/stoewer/go-strcase v1.3.1 // indirect
|
||||
github.com/twitchtv/twirp v8.1.3+incompatible // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/zeebo/xxh3 v1.0.2 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.uber.org/zap/exp v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.43.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
|
||||
golang.org/x/mod v0.29.0 // indirect
|
||||
golang.org/x/net v0.46.0 // indirect
|
||||
golang.org/x/sync v0.17.0 // indirect
|
||||
golang.org/x/sys v0.37.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect
|
||||
google.golang.org/grpc v1.76.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
291
go.sum
Normal file
291
go.sum
Normal file
@@ -0,0 +1,291 @@
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc=
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4=
|
||||
buf.build/go/protovalidate v1.0.0 h1:IAG1etULddAy93fiBsFVhpj7es5zL53AfB/79CVGtyY=
|
||||
buf.build/go/protovalidate v1.0.0/go.mod h1:KQmEUrcQuC99hAw+juzOEAmILScQiKBP1Oc36vvCLW8=
|
||||
buf.build/go/protoyaml v0.6.0 h1:Nzz1lvcXF8YgNZXk+voPPwdU8FjDPTUV4ndNTXN0n2w=
|
||||
buf.build/go/protoyaml v0.6.0/go.mod h1:RgUOsBu/GYKLDSIRgQXniXbNgFlGEZnQpRAUdLAFV2Q=
|
||||
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
|
||||
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
|
||||
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
|
||||
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
|
||||
github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4=
|
||||
github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dennwc/iters v1.2.2 h1:XH2/Etihiy9ZvPOVCR+icQXeYlhbvS7k0qro4x/2qQo=
|
||||
github.com/dennwc/iters v1.2.2/go.mod h1:M9KuuMBeyEXYTmB7EnI9SCyALFCmPWOIxn5W1L0CjGg=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/docker/cli v26.1.4+incompatible h1:I8PHdc0MtxEADqYJZvhBrW9bo8gawKwwenxRM7/rLu8=
|
||||
github.com/docker/cli v26.1.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY=
|
||||
github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/frostbyte73/core v0.1.1 h1:ChhJOR7bAKOCPbA+lqDLE2cGKlCG5JXsDvvQr4YaJIA=
|
||||
github.com/frostbyte73/core v0.1.1/go.mod h1:mhfOtR+xWAvwXiwor7jnqPMnu4fxbv1F2MwZ0BEpzZo=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
|
||||
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||
github.com/gammazero/deque v1.1.0 h1:OyiyReBbnEG2PP0Bnv1AASLIYvyKqIFN5xfl1t8oGLo=
|
||||
github.com/gammazero/deque v1.1.0/go.mod h1:JVrR+Bj1NMQbPnYclvDlvSX0nVGReLrQZ0aUMuWLctg=
|
||||
github.com/go-jose/go-jose/v3 v3.0.4 h1:Wp5HA7bLQcKnf6YYao/4kpRpVMp/yf6+pJKV8WFSaNY=
|
||||
github.com/go-jose/go-jose/v3 v3.0.4/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-webauthn/webauthn v0.15.0 h1:LR1vPv62E0/6+sTenX35QrCmpMCzLeVAcnXeH4MrbJY=
|
||||
github.com/go-webauthn/webauthn v0.15.0/go.mod h1:hcAOhVChPRG7oqG7Xj6XKN1mb+8eXTGP/B7zBLzkX5A=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ=
|
||||
github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jxskiss/base62 v1.1.0 h1:A5zbF8v8WXx2xixnAKD2w+abC+sIzYJX+nxmhA6HWFw=
|
||||
github.com/jxskiss/base62 v1.1.0/go.mod h1:HhWAlUXvxKThfOlZbcuFzsqwtF5TcqS9ru3y5GfjWAc=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lithammer/shortuuid/v4 v4.2.0 h1:LMFOzVB3996a7b8aBuEXxqOBflbfPQAiVzkIcHO0h8c=
|
||||
github.com/lithammer/shortuuid/v4 v4.2.0/go.mod h1:D5noHZ2oFw/YaKCfGy0YxyE7M0wMbezmMjPdhyEFe6Y=
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5ATTo469PQPkqzdoU7be46ryiCDO3boc=
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade h1:lpxPcglwzUWNB4J0S2qZuyMehzmR7vW9whzSwV4IGoI=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A=
|
||||
github.com/livekit/protocol v1.42.3-0.20251023002554-070839e4cae7 h1:y6+WMdvTmjQ4KiH/pKfu6vdtScw7Vj1MZfzom5MS/54=
|
||||
github.com/livekit/protocol v1.42.3-0.20251023002554-070839e4cae7/go.mod h1:ODNQZnKVH2U93PMn/NwcpPV6zOrilBpYbyncjn/rHZI=
|
||||
github.com/livekit/psrpc v0.7.0 h1:rtfqfjYN06WJYloE/S0nmkJ/Y04x4pxLQLe8kQ4FVHU=
|
||||
github.com/livekit/psrpc v0.7.0/go.mod h1:AuDC5uOoEjQJEc69v4Li3t77Ocz0e0NdjQEuFfO+vfk=
|
||||
github.com/livekit/server-sdk-go/v2 v2.12.8 h1:dZeUrGokfl9Aw/EK4Xwu0NtNUQ6zOLXggdhlCPAtLhk=
|
||||
github.com/livekit/server-sdk-go/v2 v2.12.8/go.mod h1:EGWi7fcsHawWOCxUIlnSHC3fzWBsCEscLkouIZEzGKY=
|
||||
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
|
||||
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs=
|
||||
github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
|
||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
||||
github.com/nats-io/nats.go v1.47.0 h1:YQdADw6J/UfGUd2Oy6tn4Hq6YHxCaJrVKayxxFqYrgM=
|
||||
github.com/nats-io/nats.go v1.47.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g=
|
||||
github.com/nats-io/nkeys v0.4.11 h1:q44qGV008kYd9W1b1nEBkNzvnWxtRSQ7A8BoqRrcfa0=
|
||||
github.com/nats-io/nkeys v0.4.11/go.mod h1:szDimtgmfOi9n25JpfIdGw12tZFYXqhGxjhVxsatHVE=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
|
||||
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
|
||||
github.com/opencontainers/runc v1.2.3 h1:fxE7amCzfZflJO2lHXf4y/y8M1BoAqp+FVmG19oYB80=
|
||||
github.com/opencontainers/runc v1.2.3/go.mod h1:nSxcWUydXrsBZVYNSkTjoQ/N6rcyTtn+1SD5D4+kRIM=
|
||||
github.com/ory/dockertest/v3 v3.11.0 h1:OiHcxKAvSDUwsEVh2BjxQQc/5EHz9n0va9awCtNGuyA=
|
||||
github.com/ory/dockertest/v3 v3.11.0/go.mod h1:VIPxS1gwT9NpPOrfD3rACs8Y9Z7yhzO4SB194iUDnUI=
|
||||
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
|
||||
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
||||
github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q=
|
||||
github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8=
|
||||
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
|
||||
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
|
||||
github.com/pion/interceptor v0.1.41 h1:NpvX3HgWIukTf2yTBVjVGFXtpSpWgXjqz7IIpu7NsOw=
|
||||
github.com/pion/interceptor v0.1.41/go.mod h1:nEt4187unvRXJFyjiw00GKo+kIuXMWQI9K89fsosDLY=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
|
||||
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
|
||||
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
|
||||
github.com/pion/rtp v1.8.23 h1:kxX3bN4nM97DPrVBGq5I/Xcl332HnTHeP1Swx3/MCnU=
|
||||
github.com/pion/rtp v1.8.23/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/sctp v1.8.40 h1:bqbgWYOrUhsYItEnRObUYZuzvOMsVplS3oNgzedBlG8=
|
||||
github.com/pion/sctp v1.8.40/go.mod h1:SPBBUENXE6ThkEksN5ZavfAhFYll+h+66ZiG6IZQuzo=
|
||||
github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo=
|
||||
github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
|
||||
github.com/pion/srtp/v3 v3.0.8 h1:RjRrjcIeQsilPzxvdaElN0CpuQZdMvcl9VZ5UY9suUM=
|
||||
github.com/pion/srtp/v3 v3.0.8/go.mod h1:2Sq6YnDH7/UDCvkSoHSDNDeyBcFgWL0sAVycVbAsXFg=
|
||||
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
|
||||
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU=
|
||||
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
|
||||
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc=
|
||||
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8=
|
||||
github.com/pion/webrtc/v4 v4.1.6 h1:srHH2HwvCGwPba25EYJgUzgLqCQoXl1VCUnrGQMSzUw=
|
||||
github.com/pion/webrtc/v4 v4.1.6/go.mod h1:wKecGRlkl3ox/As/MYghJL+b/cVXMEhoPMJWPuGQFhU=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg=
|
||||
github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
||||
github.com/redis/go-redis/v9 v9.14.0 h1:u4tNCjXOyzfgeLN+vAZaW1xUooqWDqVEsZN0U01jfAE=
|
||||
github.com/redis/go-redis/v9 v9.14.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk=
|
||||
github.com/shoenig/test v1.7.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs=
|
||||
github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/stripe/stripe-go/v79 v79.4.0 h1:LUo4ngSqK3Euux8XKxy9IWwYeAkMc7fZ2VGBzHQvDUU=
|
||||
github.com/stripe/stripe-go/v79 v79.4.0/go.mod h1:cuH6X0zC8peY6f1AubHwgJ/fJSn2dh5pfiCr6CjyKVU=
|
||||
github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU=
|
||||
github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
||||
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.uber.org/zap/exp v0.3.0 h1:6JYzdifzYkGmTdRR59oYH+Ng7k49H9qVpWwNSsGJj3U=
|
||||
go.uber.org/zap/exp v0.3.0/go.mod h1:5I384qq7XGxYyByIhHm6jg5CHkGY0nsTfbDLgDDlgJQ=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
|
||||
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
|
||||
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b h1:18qgiDvlvH7kk8Ioa8Ov+K6xCi0GMvmGfGW0sgd/SYA=
|
||||
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
||||
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f h1:OiFuztEyBivVKDvguQJYWq1yDcfAHIID/FVrPR4oiI0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f/go.mod h1:kprOiu9Tr0JYyD6DORrc4Hfyk3RFXqkQ3ctHEum3ZbM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f h1:1FTH6cpXFsENbPR5Bu8NQddPSaUUE6NA2XdZdDSAJK4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
||||
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
|
||||
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
94
justfile
Normal file
94
justfile
Normal file
@@ -0,0 +1,94 @@
|
||||
env_file := "dev/.env"
|
||||
compose_file := "dev/compose.yaml"
|
||||
data_compose := "dev/compose.data.yaml"
|
||||
network_name := "fluxer-shared"
|
||||
compose_base := "docker compose --env-file " + env_file + " -f " + compose_file
|
||||
livekit_template := "dev/templates/livekit.yaml"
|
||||
|
||||
up *SERVICES:
|
||||
just ensure-network
|
||||
{{compose_base}} up -d {{SERVICES}}
|
||||
|
||||
watch *SERVICES:
|
||||
just ensure-network
|
||||
{{compose_base}} watch {{SERVICES}}
|
||||
|
||||
down:
|
||||
{{compose_base}} down
|
||||
|
||||
nuke:
|
||||
{{compose_base}} down -v
|
||||
|
||||
restart *SERVICES:
|
||||
{{compose_base}} restart {{SERVICES}}
|
||||
|
||||
logs *SERVICES:
|
||||
{{compose_base}} logs -f --tail 100 {{SERVICES}}
|
||||
|
||||
ps:
|
||||
{{compose_base}} ps
|
||||
|
||||
sh SERVICE shell="sh":
|
||||
{{compose_base}} exec {{SERVICE}} {{shell}}
|
||||
|
||||
exec SERVICE CMD:
|
||||
{{compose_base}} exec {{SERVICE}} sh -c "{{CMD}}"
|
||||
|
||||
livekit-sync:
|
||||
set -euo pipefail
|
||||
if [ ! -f {{env_file}} ]; then
|
||||
echo "{{env_file}} missing"
|
||||
exit 1
|
||||
fi
|
||||
node --env-file {{env_file}} scripts/just/livekit-sync.js --output dev/livekit.yaml
|
||||
|
||||
ensure-network:
|
||||
set -euo pipefail
|
||||
docker network inspect {{network_name}} >/dev/null 2>&1 || docker network create {{network_name}}
|
||||
|
||||
bootstrap:
|
||||
just ensure-network
|
||||
just livekit-sync
|
||||
|
||||
setup:
|
||||
set -euo pipefail
|
||||
just ensure-network
|
||||
if [ ! -f dev/.env ]; then
|
||||
cp dev/.env.example dev/.env
|
||||
fi
|
||||
if [ ! -f dev/livekit.yaml ]; then
|
||||
cp {{livekit_template}} dev/livekit.yaml
|
||||
fi
|
||||
|
||||
mig name:
|
||||
@cargo run --release --quiet --manifest-path scripts/cassandra-migrate/Cargo.toml -- create "{{name}}"
|
||||
|
||||
mig-check:
|
||||
@cargo run --release --quiet --manifest-path scripts/cassandra-migrate/Cargo.toml -- check
|
||||
|
||||
mig-up host="localhost" user="cassandra" pass="cassandra":
|
||||
@cargo run --release --quiet --manifest-path scripts/cassandra-migrate/Cargo.toml -- --host "{{host}}" --username "{{user}}" --password "{{pass}}" up
|
||||
|
||||
mig-status host="localhost" user="cassandra" pass="cassandra":
|
||||
@cargo run --release --quiet --manifest-path scripts/cassandra-migrate/Cargo.toml -- --host "{{host}}" --username "{{user}}" --password "{{pass}}" status
|
||||
|
||||
lic:
|
||||
@cargo run --release --quiet --manifest-path scripts/license-enforcer/Cargo.toml
|
||||
|
||||
snow count="1":
|
||||
@cargo run --release --quiet --manifest-path scripts/snowflake-generator/Cargo.toml -- --count {{count}}
|
||||
|
||||
integration-tests:
|
||||
set -euo pipefail
|
||||
trap 'docker compose -f tests/integration/compose.yaml down' EXIT
|
||||
docker compose -f tests/integration/compose.yaml up --build --abort-on-container-exit integration-tests
|
||||
|
||||
go-tools-install:
|
||||
GOTOOLCHAIN=go1.25.5 go install honnef.co/go/tools/cmd/staticcheck@2025.1.1
|
||||
GOTOOLCHAIN=go1.25.5 go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
|
||||
|
||||
go-integration-check:
|
||||
gofmt -w tests/integration
|
||||
go test ./tests/integration/...
|
||||
$(go env GOPATH)/bin/staticcheck ./tests/integration/...
|
||||
$(go env GOPATH)/bin/golangci-lint run ./tests/integration/...
|
||||
BIN
media/app-showcase.png
Normal file
BIN
media/app-showcase.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
BIN
media/logo-graphic.png
Normal file
BIN
media/logo-graphic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
25
package.json
Normal file
25
package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "fluxer",
|
||||
"private": true,
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": true,
|
||||
"plugins": [
|
||||
"prettier-plugin-astro"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.3.10",
|
||||
"prettier": "3.7.4",
|
||||
"prettier-plugin-astro": "0.14.1",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@biomejs/biome"
|
||||
]
|
||||
}
|
||||
}
|
||||
162
pnpm-lock.yaml
generated
Normal file
162
pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,162 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
devDependencies:
|
||||
'@biomejs/biome':
|
||||
specifier: 2.3.10
|
||||
version: 2.3.10
|
||||
prettier:
|
||||
specifier: 3.7.4
|
||||
version: 3.7.4
|
||||
prettier-plugin-astro:
|
||||
specifier: 0.14.1
|
||||
version: 0.14.1
|
||||
typescript:
|
||||
specifier: 5.9.3
|
||||
version: 5.9.3
|
||||
|
||||
packages:
|
||||
|
||||
'@astrojs/compiler@2.13.0':
|
||||
resolution: {integrity: sha512-mqVORhUJViA28fwHYaWmsXSzLO9osbdZ5ImUfxBarqsYdMlPbqAqGJCxsNzvppp1BEzc1mJNjOVvQqeDN8Vspw==}
|
||||
|
||||
'@biomejs/biome@2.3.10':
|
||||
resolution: {integrity: sha512-/uWSUd1MHX2fjqNLHNL6zLYWBbrJeG412/8H7ESuK8ewoRoMPUgHDebqKrPTx/5n6f17Xzqc9hdg3MEqA5hXnQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
hasBin: true
|
||||
|
||||
'@biomejs/cli-darwin-arm64@2.3.10':
|
||||
resolution: {integrity: sha512-M6xUjtCVnNGFfK7HMNKa593nb7fwNm43fq1Mt71kpLpb+4mE7odO8W/oWVDyBVO4ackhresy1ZYO7OJcVo/B7w==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-darwin-x64@2.3.10':
|
||||
resolution: {integrity: sha512-Vae7+V6t/Avr8tVbFNjnFSTKZogZHFYl7MMH62P/J1kZtr0tyRQ9Fe0onjqjS2Ek9lmNLmZc/VR5uSekh+p1fg==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@2.3.10':
|
||||
resolution: {integrity: sha512-B9DszIHkuKtOH2IFeeVkQmSMVUjss9KtHaNXquYYWCjH8IstNgXgx5B0aSBQNr6mn4RcKKRQZXn9Zu1rM3O0/A==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-arm64@2.3.10':
|
||||
resolution: {integrity: sha512-hhPw2V3/EpHKsileVOFynuWiKRgFEV48cLe0eA+G2wO4SzlwEhLEB9LhlSrVeu2mtSn205W283LkX7Fh48CaxA==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@2.3.10':
|
||||
resolution: {integrity: sha512-QTfHZQh62SDFdYc2nfmZFuTm5yYb4eO1zwfB+90YxUumRCR171tS1GoTX5OD0wrv4UsziMPmrePMtkTnNyYG3g==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64@2.3.10':
|
||||
resolution: {integrity: sha512-wwAkWD1MR95u+J4LkWP74/vGz+tRrIQvr8kfMMJY8KOQ8+HMVleREOcPYsQX82S7uueco60L58Wc6M1I9WA9Dw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-win32-arm64@2.3.10':
|
||||
resolution: {integrity: sha512-o7lYc9n+CfRbHvkjPhm8s9FgbKdYZu5HCcGVMItLjz93EhgJ8AM44W+QckDqLA9MKDNFrR8nPbO4b73VC5kGGQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@biomejs/cli-win32-x64@2.3.10':
|
||||
resolution: {integrity: sha512-pHEFgq7dUEsKnqG9mx9bXihxGI49X+ar+UBrEIj3Wqj3UCZp1rNgV+OoyjFgcXsjCWpuEAF4VJdkZr3TrWdCbQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
prettier-plugin-astro@0.14.1:
|
||||
resolution: {integrity: sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==}
|
||||
engines: {node: ^14.15.0 || >=16.0.0}
|
||||
|
||||
prettier@3.7.4:
|
||||
resolution: {integrity: sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
|
||||
s.color@0.0.15:
|
||||
resolution: {integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==}
|
||||
|
||||
sass-formatter@0.7.9:
|
||||
resolution: {integrity: sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==}
|
||||
|
||||
suf-log@2.5.3:
|
||||
resolution: {integrity: sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==}
|
||||
|
||||
typescript@5.9.3:
|
||||
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@astrojs/compiler@2.13.0': {}
|
||||
|
||||
'@biomejs/biome@2.3.10':
|
||||
optionalDependencies:
|
||||
'@biomejs/cli-darwin-arm64': 2.3.10
|
||||
'@biomejs/cli-darwin-x64': 2.3.10
|
||||
'@biomejs/cli-linux-arm64': 2.3.10
|
||||
'@biomejs/cli-linux-arm64-musl': 2.3.10
|
||||
'@biomejs/cli-linux-x64': 2.3.10
|
||||
'@biomejs/cli-linux-x64-musl': 2.3.10
|
||||
'@biomejs/cli-win32-arm64': 2.3.10
|
||||
'@biomejs/cli-win32-x64': 2.3.10
|
||||
|
||||
'@biomejs/cli-darwin-arm64@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-darwin-x64@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-arm64@2.3.10':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-x64@2.3.10':
|
||||
optional: true
|
||||
|
||||
prettier-plugin-astro@0.14.1:
|
||||
dependencies:
|
||||
'@astrojs/compiler': 2.13.0
|
||||
prettier: 3.7.4
|
||||
sass-formatter: 0.7.9
|
||||
|
||||
prettier@3.7.4: {}
|
||||
|
||||
s.color@0.0.15: {}
|
||||
|
||||
sass-formatter@0.7.9:
|
||||
dependencies:
|
||||
suf-log: 2.5.3
|
||||
|
||||
suf-log@2.5.3:
|
||||
dependencies:
|
||||
s.color: 0.0.15
|
||||
|
||||
typescript@5.9.3: {}
|
||||
1432
scripts/cassandra-migrate/Cargo.lock
generated
Normal file
1432
scripts/cassandra-migrate/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
scripts/cassandra-migrate/Cargo.toml
Normal file
22
scripts/cassandra-migrate/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "cassandra-migrate"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
scylla = "0.9"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
anyhow = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
md5 = "0.7"
|
||||
regex = "1.10"
|
||||
lazy_static = "1.4"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
opt-level = "z"
|
||||
21
scripts/cassandra-migrate/Dockerfile
Normal file
21
scripts/cassandra-migrate/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM rustlang/rust:nightly AS builder
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY scripts/cassandra-migrate/Cargo.toml scripts/cassandra-migrate/Cargo.toml
|
||||
COPY scripts/cassandra-migrate/Cargo.lock scripts/cassandra-migrate/Cargo.lock
|
||||
COPY scripts/cassandra-migrate/src scripts/cassandra-migrate/src
|
||||
|
||||
WORKDIR /workspace/scripts/cassandra-migrate
|
||||
RUN cargo build --release
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /workspace/scripts/cassandra-migrate/target/release/cassandra-migrate /usr/local/bin/cassandra-migrate
|
||||
COPY fluxer_devops/cassandra/migrations fluxer_devops/cassandra/migrations
|
||||
|
||||
ENTRYPOINT ["cassandra-migrate"]
|
||||
110
scripts/cassandra-migrate/src/main.rs
Normal file
110
scripts/cassandra-migrate/src/main.rs
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::env;
|
||||
|
||||
mod migrate;
|
||||
|
||||
fn get_env_or_default(key: &str, default: &str) -> String {
|
||||
env::var(key).unwrap_or_else(|_| default.to_string())
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "cassandra-migrate")]
|
||||
#[command(about = "Forward-only Cassandra migration tool for Fluxer", long_about = Some("A simple, forward-only migration tool for Cassandra.\nMigrations are stored in fluxer_devops/cassandra/migrations.\nMigration metadata is stored in the 'fluxer' keyspace."))]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
|
||||
#[arg(long, default_value_t = get_env_or_default("CASSANDRA_HOST", "localhost"))]
|
||||
host: String,
|
||||
|
||||
#[arg(long, default_value = "9042")]
|
||||
port: u16,
|
||||
|
||||
#[arg(long, default_value_t = get_env_or_default("CASSANDRA_USERNAME", "cassandra"))]
|
||||
username: String,
|
||||
|
||||
#[arg(long, default_value_t = get_env_or_default("CASSANDRA_PASSWORD", "cassandra"))]
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Create a new migration file
|
||||
Create {
|
||||
/// Name of the migration
|
||||
name: String,
|
||||
},
|
||||
/// Validate all migration files
|
||||
Check,
|
||||
/// Run pending migrations
|
||||
Up,
|
||||
/// Acknowledge a failed migration to skip it
|
||||
Ack {
|
||||
/// Filename of the migration to acknowledge
|
||||
filename: String,
|
||||
},
|
||||
/// Show migration status
|
||||
Status,
|
||||
/// Test Cassandra connection
|
||||
Test,
|
||||
/// Debug Cassandra connection
|
||||
Debug,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
match cli.command {
|
||||
Commands::Create { name } => {
|
||||
migrate::create_migration(&name)?;
|
||||
}
|
||||
Commands::Check => {
|
||||
migrate::check_migrations()?;
|
||||
}
|
||||
Commands::Up => {
|
||||
migrate::run_migrations(&cli.host, cli.port, &cli.username, &cli.password).await?;
|
||||
}
|
||||
Commands::Ack { filename } => {
|
||||
migrate::acknowledge_migration(
|
||||
&cli.host,
|
||||
cli.port,
|
||||
&cli.username,
|
||||
&cli.password,
|
||||
&filename,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Commands::Status => {
|
||||
migrate::show_status(&cli.host, cli.port, &cli.username, &cli.password).await?;
|
||||
}
|
||||
Commands::Test => {
|
||||
migrate::test_connection(&cli.host, cli.port, &cli.username, &cli.password).await?;
|
||||
}
|
||||
Commands::Debug => {
|
||||
migrate::debug_connection(&cli.host, cli.port, &cli.username, &cli.password).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
682
scripts/cassandra-migrate/src/migrate.rs
Normal file
682
scripts/cassandra-migrate/src/migrate.rs
Normal file
@@ -0,0 +1,682 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use chrono::{DateTime, Utc};
|
||||
use regex::Regex;
|
||||
use scylla::Session;
|
||||
use scylla::SessionBuilder;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const MIGRATION_TABLE: &str = "schema_migrations";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref MIGRATION_KEYSPACE: String = env::var("CASSANDRA_KEYSPACE").unwrap_or_else(|_| "fluxer".to_string());
|
||||
}
|
||||
|
||||
fn migration_keyspace() -> &'static str {
|
||||
MIGRATION_KEYSPACE.as_str()
|
||||
}
|
||||
|
||||
const MIGRATION_TEMPLATE: &str = "";
|
||||
|
||||
struct ForbiddenPattern {
|
||||
pattern: Regex,
|
||||
message: &'static str,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref FORBIDDEN_PATTERNS: Vec<ForbiddenPattern> = vec![
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bCREATE\s+INDEX\b").unwrap(),
|
||||
message: "Secondary indexes are forbidden (CREATE INDEX)",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bCREATE\s+CUSTOM\s+INDEX\b").unwrap(),
|
||||
message: "Custom indexes are forbidden (CREATE CUSTOM INDEX)",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bCREATE\s+MATERIALIZED\s+VIEW\b").unwrap(),
|
||||
message: "Materialized views are forbidden (CREATE MATERIALIZED VIEW)",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+TABLE\b").unwrap(),
|
||||
message: "DROP TABLE is forbidden",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+KEYSPACE\b").unwrap(),
|
||||
message: "DROP KEYSPACE is forbidden",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+TYPE\b").unwrap(),
|
||||
message: "DROP TYPE is forbidden",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+INDEX\b").unwrap(),
|
||||
message: "DROP INDEX is forbidden",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+MATERIALIZED\s+VIEW\b").unwrap(),
|
||||
message: "DROP MATERIALIZED VIEW is forbidden",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bDROP\s+COLUMN\b").unwrap(),
|
||||
message: "DROP COLUMN is forbidden (use ALTER TABLE ... DROP ...)",
|
||||
},
|
||||
ForbiddenPattern {
|
||||
pattern: Regex::new(r"(?i)\bTRUNCATE\b").unwrap(),
|
||||
message: "TRUNCATE is forbidden",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
pub async fn test_connection(host: &str, port: u16, username: &str, password: &str) -> Result<()> {
|
||||
println!("Testing Cassandra connection to {host}:{port}...");
|
||||
|
||||
let session = create_session(host, port, username, password).await?;
|
||||
|
||||
let result = session
|
||||
.query("SELECT release_version FROM system.local", &[])
|
||||
.await?;
|
||||
|
||||
if let Some(rows) = result.rows
|
||||
&& let Some(row) = rows.into_iter().next()
|
||||
&& let Some(cql_value) = &row.columns[0]
|
||||
&& let Some(version) = cql_value.as_text()
|
||||
{
|
||||
println!("✓ Connection successful - Cassandra version: {version}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("✓ Connection successful");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_migration(name: &str) -> Result<()> {
|
||||
let sanitized = sanitize_name(name);
|
||||
if sanitized.is_empty() {
|
||||
return Err(anyhow!("Invalid migration name: {name}"));
|
||||
}
|
||||
|
||||
let timestamp = Utc::now().format("%Y%m%d%H%M%S");
|
||||
let filename = format!("{timestamp}_{sanitized}.cql");
|
||||
|
||||
let filepath = get_migration_path(&filename);
|
||||
|
||||
if filepath.exists() {
|
||||
return Err(anyhow!("Migration file already exists: {filename}"));
|
||||
}
|
||||
|
||||
fs::write(&filepath, MIGRATION_TEMPLATE)?;
|
||||
|
||||
println!("✓ Created migration: {filename}");
|
||||
println!(" Path: {}", filepath.display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_migrations() -> Result<()> {
|
||||
let migrations = get_migration_files()?;
|
||||
|
||||
if migrations.is_empty() {
|
||||
println!("No migration files found");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("Checking {} migration file(s)...\n", migrations.len());
|
||||
|
||||
let mut errors = Vec::new();
|
||||
let mut valid_count = 0;
|
||||
|
||||
for migration in &migrations {
|
||||
let content = fs::read_to_string(get_migration_path(migration))?;
|
||||
let file_errors = validate_migration_content(migration, &content);
|
||||
|
||||
if file_errors.is_empty() {
|
||||
valid_count += 1;
|
||||
println!("✓ {migration}");
|
||||
} else {
|
||||
errors.extend(file_errors);
|
||||
}
|
||||
}
|
||||
|
||||
if !errors.is_empty() {
|
||||
println!("\nValidation errors:");
|
||||
for error in &errors {
|
||||
println!("✗ {error}");
|
||||
}
|
||||
return Err(anyhow!("Validation failed with {} error(s)", errors.len()));
|
||||
}
|
||||
|
||||
println!("\n✓ All {valid_count} migration(s) are valid!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run_migrations(host: &str, port: u16, username: &str, password: &str) -> Result<()> {
|
||||
println!("Starting Cassandra migration process...");
|
||||
println!("Host: {host}, Port: {port}");
|
||||
|
||||
let session = create_session(host, port, username, password).await?;
|
||||
|
||||
setup_migration_infrastructure(&session).await?;
|
||||
|
||||
let migrations = get_migration_files()?;
|
||||
let applied = get_applied_migrations(&session).await?;
|
||||
|
||||
if migrations.is_empty() {
|
||||
println!("No migration files found");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut pending = Vec::new();
|
||||
let mut skipped = Vec::new();
|
||||
|
||||
for migration in migrations {
|
||||
if !applied.contains_key(&migration) {
|
||||
if has_skip_ci(&migration)? {
|
||||
skipped.push(migration);
|
||||
} else {
|
||||
pending.push(migration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !skipped.is_empty() {
|
||||
println!(
|
||||
"Found {} migration(s) with '-- skip ci' annotation:",
|
||||
skipped.len()
|
||||
);
|
||||
for migration in &skipped {
|
||||
println!(" - {migration}");
|
||||
}
|
||||
println!("\nAuto-acknowledging skipped migrations...");
|
||||
|
||||
for migration in &skipped {
|
||||
auto_acknowledge_migration(&session, migration).await?;
|
||||
println!(" ✓ Acknowledged: {migration}");
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
||||
if pending.is_empty() {
|
||||
println!("✓ No pending migrations");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("Found {} pending migration(s) to apply:", pending.len());
|
||||
for migration in &pending {
|
||||
println!(" - {migration}");
|
||||
}
|
||||
println!();
|
||||
|
||||
let pending_count = pending.len();
|
||||
for migration in pending {
|
||||
apply_migration(&session, &migration).await?;
|
||||
}
|
||||
|
||||
println!("✓ Successfully applied {pending_count} migration(s)");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn show_status(host: &str, port: u16, username: &str, password: &str) -> Result<()> {
|
||||
let session = create_session(host, port, username, password).await?;
|
||||
|
||||
let migrations = get_migration_files()?;
|
||||
let applied = get_applied_migrations(&session).await?;
|
||||
|
||||
println!("Migration Status");
|
||||
println!("================\n");
|
||||
println!("Total migrations: {}", migrations.len());
|
||||
println!("Applied: {}", applied.len());
|
||||
println!("Pending: {}\n", migrations.len() - applied.len());
|
||||
|
||||
if !migrations.is_empty() {
|
||||
println!("Migrations:");
|
||||
for migration in migrations {
|
||||
let status = if applied.contains_key(&migration) {
|
||||
"[✓]"
|
||||
} else {
|
||||
"[ ]"
|
||||
};
|
||||
|
||||
let suffix = if has_skip_ci(&migration)? {
|
||||
" (skip ci)"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
println!(" {status} {migration}{suffix}");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn acknowledge_migration(
|
||||
host: &str,
|
||||
port: u16,
|
||||
username: &str,
|
||||
password: &str,
|
||||
filename: &str,
|
||||
) -> Result<()> {
|
||||
let session = create_session(host, port, username, password).await?;
|
||||
|
||||
let applied = get_applied_migrations(&session).await?;
|
||||
if applied.contains_key(filename) {
|
||||
return Err(anyhow!("Migration {filename} is already applied"));
|
||||
}
|
||||
|
||||
let content = fs::read_to_string(get_migration_path(filename))?;
|
||||
let checksum = calculate_checksum(&content);
|
||||
|
||||
session
|
||||
.query(
|
||||
format!(
|
||||
"INSERT INTO {}.{} (filename, applied_at, checksum) VALUES (?, ?, ?)",
|
||||
migration_keyspace(),
|
||||
MIGRATION_TABLE
|
||||
),
|
||||
(filename, Utc::now(), checksum),
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("✓ Migration acknowledged: {filename}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn create_session(host: &str, port: u16, username: &str, password: &str) -> Result<Session> {
|
||||
let max_retries = 5;
|
||||
let retry_delay = Duration::from_secs(10);
|
||||
|
||||
let mut last_error = None;
|
||||
|
||||
for attempt in 1..=max_retries {
|
||||
if attempt > 1 {
|
||||
println!("Retrying connection (attempt {attempt}/{max_retries})...");
|
||||
}
|
||||
|
||||
let result = SessionBuilder::new()
|
||||
.known_node(format!("{host}:{port}"))
|
||||
.user(username, password)
|
||||
.connection_timeout(Duration::from_secs(60))
|
||||
.build()
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(session) => {
|
||||
let _ = session
|
||||
.query(
|
||||
format!(
|
||||
"CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}",
|
||||
migration_keyspace()
|
||||
),
|
||||
&[],
|
||||
)
|
||||
.await;
|
||||
|
||||
return Ok(session);
|
||||
}
|
||||
Err(e) => {
|
||||
last_error = Some(e);
|
||||
|
||||
if attempt < max_retries {
|
||||
tokio::time::sleep(retry_delay).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
"Failed to connect to Cassandra after {} attempts: {}",
|
||||
max_retries,
|
||||
last_error.unwrap()
|
||||
))
|
||||
}
|
||||
|
||||
async fn setup_migration_infrastructure(session: &Session) -> Result<()> {
|
||||
session
|
||||
.query(
|
||||
format!(
|
||||
"CREATE TABLE IF NOT EXISTS {}.{} (filename text PRIMARY KEY, applied_at timestamp, checksum text)",
|
||||
migration_keyspace(),
|
||||
MIGRATION_TABLE
|
||||
),
|
||||
&[],
|
||||
)
|
||||
.await
|
||||
.map_err(|e| anyhow!("Failed to create migrations table: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn apply_migration(session: &Session, filename: &str) -> Result<()> {
|
||||
println!("Applying migration: {filename}");
|
||||
|
||||
let content = fs::read_to_string(get_migration_path(filename))?;
|
||||
let statements = parse_statements(&content);
|
||||
|
||||
if statements.is_empty() {
|
||||
return Err(anyhow!("No valid statements found in migration"));
|
||||
}
|
||||
|
||||
println!(" Executing {} statement(s)...", statements.len());
|
||||
|
||||
for (i, statement) in statements.iter().enumerate() {
|
||||
println!(" [{}/{}] Executing...", i + 1, statements.len());
|
||||
|
||||
session
|
||||
.query(statement.as_str(), &[])
|
||||
.await
|
||||
.map_err(|e| anyhow!("Statement {} failed: {}\n{}", i + 1, e, statement))?;
|
||||
}
|
||||
|
||||
let checksum = calculate_checksum(&content);
|
||||
session
|
||||
.query(
|
||||
format!(
|
||||
"INSERT INTO {}.{} (filename, applied_at, checksum) VALUES (?, ?, ?)",
|
||||
migration_keyspace(),
|
||||
MIGRATION_TABLE
|
||||
),
|
||||
(filename, Utc::now(), checksum),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| anyhow!("Failed to record migration: {e}"))?;
|
||||
|
||||
println!(" ✓ Migration applied successfully");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn auto_acknowledge_migration(session: &Session, filename: &str) -> Result<()> {
|
||||
let content = fs::read_to_string(get_migration_path(filename))?;
|
||||
let checksum = calculate_checksum(&content);
|
||||
|
||||
session
|
||||
.query(
|
||||
format!(
|
||||
"INSERT INTO {}.{} (filename, applied_at, checksum) VALUES (?, ?, ?)",
|
||||
migration_keyspace(),
|
||||
MIGRATION_TABLE
|
||||
),
|
||||
(filename, Utc::now(), checksum),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| anyhow!("Failed to record migration: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_applied_migrations(session: &Session) -> Result<HashMap<String, DateTime<Utc>>> {
|
||||
let mut applied = HashMap::new();
|
||||
|
||||
let result = session
|
||||
.query(
|
||||
format!(
|
||||
"SELECT filename, applied_at FROM {}.{}",
|
||||
migration_keyspace(),
|
||||
MIGRATION_TABLE
|
||||
),
|
||||
&[],
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(rows) = result.rows {
|
||||
for row in rows {
|
||||
if let Some(filename_cql) = &row.columns[0]
|
||||
&& let Some(filename) = filename_cql.as_text()
|
||||
&& let Some(applied_at_cql) = &row.columns[1]
|
||||
{
|
||||
use scylla::frame::response::result::CqlValue;
|
||||
if let CqlValue::Timestamp(duration) = applied_at_cql {
|
||||
let millis = duration.num_milliseconds();
|
||||
let applied_at: DateTime<Utc> = DateTime::from_timestamp(
|
||||
millis / 1000,
|
||||
((millis % 1000) * 1_000_000) as u32,
|
||||
)
|
||||
.unwrap_or(Utc::now());
|
||||
applied.insert(filename.to_string(), applied_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(applied)
|
||||
}
|
||||
|
||||
fn get_migration_files() -> Result<Vec<String>> {
|
||||
let migrations_dir = get_migrations_dir();
|
||||
let mut migrations = Vec::new();
|
||||
|
||||
for entry in fs::read_dir(migrations_dir)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
|
||||
if path.is_file()
|
||||
&& path.extension().is_some_and(|ext| ext == "cql")
|
||||
&& let Some(filename) = path.file_name().and_then(|n| n.to_str())
|
||||
{
|
||||
migrations.push(filename.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
migrations.sort();
|
||||
Ok(migrations)
|
||||
}
|
||||
|
||||
fn get_migrations_dir() -> PathBuf {
|
||||
PathBuf::from("fluxer_devops/cassandra/migrations")
|
||||
}
|
||||
|
||||
fn get_migration_path(filename: &str) -> PathBuf {
|
||||
get_migrations_dir().join(filename)
|
||||
}
|
||||
|
||||
fn has_skip_ci(filename: &str) -> Result<bool> {
|
||||
let content = fs::read_to_string(get_migration_path(filename))?;
|
||||
let lines: Vec<&str> = content.lines().take(10).collect();
|
||||
|
||||
for line in lines {
|
||||
let line = line.trim().to_lowercase();
|
||||
if line.contains("-- skip ci") || line.contains("--skip ci") {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn parse_statements(content: &str) -> Vec<String> {
|
||||
let mut statements = Vec::new();
|
||||
let mut current_statement = String::new();
|
||||
|
||||
for line in content.lines() {
|
||||
let line = if let Some(idx) = line.find("--") {
|
||||
&line[..idx]
|
||||
} else {
|
||||
line
|
||||
};
|
||||
|
||||
let trimmed = line.trim();
|
||||
|
||||
if trimmed.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
current_statement.push_str(trimmed);
|
||||
current_statement.push(' ');
|
||||
|
||||
if trimmed.ends_with(';') {
|
||||
let statement = current_statement.trim().to_string();
|
||||
if !statement.is_empty() {
|
||||
statements.push(statement);
|
||||
}
|
||||
current_statement.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if !current_statement.trim().is_empty() {
|
||||
statements.push(current_statement.trim().to_string());
|
||||
}
|
||||
|
||||
statements
|
||||
}
|
||||
|
||||
fn calculate_checksum(content: &str) -> String {
|
||||
format!("{:x}", md5::compute(content.as_bytes()))
|
||||
}
|
||||
|
||||
fn sanitize_name(name: &str) -> String {
|
||||
let mut name = name.replace(' ', "_");
|
||||
name = name.replace('-', "_");
|
||||
name = name.to_lowercase();
|
||||
|
||||
let result: String = name
|
||||
.chars()
|
||||
.filter(|c| c.is_ascii_alphanumeric() || *c == '_')
|
||||
.collect();
|
||||
|
||||
let mut result = result.replace("__", "_");
|
||||
while result.contains("__") {
|
||||
result = result.replace("__", "_");
|
||||
}
|
||||
|
||||
result.trim_matches('_').to_string()
|
||||
}
|
||||
|
||||
fn validate_migration_content(filename: &str, content: &str) -> Vec<String> {
|
||||
let mut errors = Vec::new();
|
||||
|
||||
let clean_content = remove_comments(content);
|
||||
|
||||
for forbidden in FORBIDDEN_PATTERNS.iter() {
|
||||
if forbidden.pattern.is_match(&clean_content) {
|
||||
errors.push(format!(" {}: {}", filename, forbidden.message));
|
||||
}
|
||||
}
|
||||
|
||||
if clean_content.trim().is_empty() {
|
||||
errors.push(format!(" {filename}: migration file is empty"));
|
||||
}
|
||||
|
||||
errors
|
||||
}
|
||||
|
||||
fn remove_comments(content: &str) -> String {
|
||||
content
|
||||
.lines()
|
||||
.map(|line| {
|
||||
if let Some(idx) = line.find("--") {
|
||||
&line[..idx]
|
||||
} else {
|
||||
line
|
||||
}
|
||||
})
|
||||
.map(str::trim)
|
||||
.filter(|line| !line.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
pub async fn debug_connection(host: &str, port: u16, username: &str, password: &str) -> Result<()> {
|
||||
println!("=== Cassandra Connection Debug ===");
|
||||
println!("Host: {host}:{port}");
|
||||
println!("Username: {username}");
|
||||
|
||||
println!("\n[1/3] Testing TCP connectivity...");
|
||||
let start = Instant::now();
|
||||
match tokio::time::timeout(
|
||||
Duration::from_secs(5),
|
||||
tokio::net::TcpStream::connect(format!("{host}:{port}")),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(_)) => {
|
||||
println!(
|
||||
" ✓ TCP connection successful ({:.2}s)",
|
||||
start.elapsed().as_secs_f64()
|
||||
);
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
println!(" ✗ TCP connection failed: {e}");
|
||||
return Err(anyhow!("TCP connection failed: {e}"));
|
||||
}
|
||||
Err(_) => {
|
||||
println!(" ✗ TCP connection timed out");
|
||||
return Err(anyhow!("TCP connection timed out"));
|
||||
}
|
||||
}
|
||||
|
||||
println!("\n[2/3] Creating Cassandra session...");
|
||||
let start = Instant::now();
|
||||
let session = match tokio::time::timeout(
|
||||
Duration::from_secs(30),
|
||||
SessionBuilder::new()
|
||||
.known_node(format!("{host}:{port}"))
|
||||
.user(username, password)
|
||||
.connection_timeout(Duration::from_secs(20))
|
||||
.build(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(session)) => {
|
||||
println!(
|
||||
" ✓ Session created ({:.2}s)",
|
||||
start.elapsed().as_secs_f64()
|
||||
);
|
||||
session
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
println!(" ✗ Session creation failed: {e}");
|
||||
return Err(anyhow!("Failed to create session: {e}"));
|
||||
}
|
||||
Err(_) => {
|
||||
println!(" ✗ Session creation timed out");
|
||||
return Err(anyhow!("Session creation timed out"));
|
||||
}
|
||||
};
|
||||
|
||||
println!("\n[3/3] Testing queries...");
|
||||
let start = Instant::now();
|
||||
let result = session
|
||||
.query("SELECT release_version FROM system.local", &[])
|
||||
.await?;
|
||||
|
||||
if let Some(rows) = result.rows
|
||||
&& let Some(row) = rows.into_iter().next()
|
||||
&& let Some(version_col) = &row.columns[0]
|
||||
&& let Some(version) = version_col.as_text()
|
||||
{
|
||||
println!(
|
||||
" ✓ Cassandra version: {} ({:.2}s)",
|
||||
version,
|
||||
start.elapsed().as_secs_f64()
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
" ✓ Query successful ({:.2}s)",
|
||||
start.elapsed().as_secs_f64()
|
||||
);
|
||||
}
|
||||
|
||||
println!("\n✓ All debug checks passed");
|
||||
Ok(())
|
||||
}
|
||||
51
scripts/just/livekit-sync.js
Executable file
51
scripts/just/livekit-sync.js
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const outputIdx = args.indexOf('--output');
|
||||
const outputArg = outputIdx >= 0 && args[outputIdx + 1] ? args[outputIdx + 1] : 'dev/livekit.yaml';
|
||||
|
||||
const voiceEnabled = (process.env.VOICE_ENABLED || '').trim().toLowerCase() === 'true';
|
||||
if (!voiceEnabled) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const apiKey = (process.env.LIVEKIT_API_KEY || '').trim();
|
||||
const apiSecret = (process.env.LIVEKIT_API_SECRET || '').trim();
|
||||
const webhookUrl = (process.env.LIVEKIT_WEBHOOK_URL || '').trim();
|
||||
if (!apiKey || !apiSecret || !webhookUrl) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const redisUrl = (process.env.REDIS_URL || '').trim();
|
||||
const redisAddr = redisUrl.replace(/^redis:\/\//, '') || 'redis:6379';
|
||||
|
||||
const yaml = `port: 7880
|
||||
|
||||
redis:
|
||||
address: "${redisAddr}"
|
||||
db: 0
|
||||
|
||||
keys:
|
||||
"${apiKey}": "${apiSecret}"
|
||||
|
||||
rtc:
|
||||
tcp_port: 7881
|
||||
|
||||
webhook:
|
||||
api_key: "${apiKey}"
|
||||
urls:
|
||||
- "${webhookUrl}"
|
||||
|
||||
room:
|
||||
auto_create: true
|
||||
max_participants: 100
|
||||
empty_timeout: 300
|
||||
|
||||
development: true
|
||||
|
||||
`;
|
||||
const outputPath = path.resolve(outputArg);
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true});
|
||||
fs.writeFileSync(outputPath, yaml, {encoding: 'utf-8', mode: 0o600});
|
||||
381
scripts/license-enforcer/Cargo.lock
generated
Normal file
381
scripts/license-enforcer/Cargo.lock
generated
Normal file
@@ -0,0 +1,381 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
|
||||
[[package]]
|
||||
name = "license-enforcer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"regex",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
15
scripts/license-enforcer/Cargo.toml
Normal file
15
scripts/license-enforcer/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "license-enforcer"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
walkdir = "2.4"
|
||||
regex = "1.10"
|
||||
chrono = "0.4"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
opt-level = "z"
|
||||
426
scripts/license-enforcer/src/main.rs
Normal file
426
scripts/license-enforcer/src/main.rs
Normal file
@@ -0,0 +1,426 @@
|
||||
#![allow(clippy::four_forward_slashes)]
|
||||
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use regex::Regex;
|
||||
use std::fs;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
const TS_LICENSE_HEADER: &str = r"/*
|
||||
* Copyright (C) {year} Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/";
|
||||
|
||||
const ERLANG_LICENSE_HEADER: &str = r"%% Copyright (C) {year} Fluxer Contributors
|
||||
%%
|
||||
%% This file is part of Fluxer.
|
||||
%%
|
||||
%% Fluxer is free software: you can redistribute it and/or modify
|
||||
%% it under the terms of the GNU Affero General Public License as published by
|
||||
%% the Free Software Foundation, either version 3 of the License, or
|
||||
%% (at your option) any later version.
|
||||
%%
|
||||
%% Fluxer is distributed in the hope that it will be useful,
|
||||
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
%% GNU Affero General Public License for more details.
|
||||
%%
|
||||
%% You should have received a copy of the GNU Affero General Public License
|
||||
%% along with Fluxer. If not, see <https://www.gnu.org/licenses/>.";
|
||||
|
||||
const GLEAM_LICENSE_HEADER: &str = r"//// Copyright (C) {year} Fluxer Contributors
|
||||
////
|
||||
//// This file is part of Fluxer.
|
||||
////
|
||||
//// Fluxer is free software: you can redistribute it and/or modify
|
||||
//// it under the terms of the GNU Affero General Public License as published by
|
||||
//// the Free Software Foundation, either version 3 of the License, or
|
||||
//// (at your option) any later version.
|
||||
////
|
||||
//// Fluxer is distributed in the hope that it will be useful,
|
||||
//// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//// GNU Affero General Public License for more details.
|
||||
////
|
||||
//// You should have received a copy of the GNU Affero General Public License
|
||||
//// along with Fluxer. If not, see <https://www.gnu.org/licenses/>.";
|
||||
|
||||
const SHELL_LICENSE_HEADER: &str = r"# Copyright (C) {year} Fluxer Contributors
|
||||
#
|
||||
# This file is part of Fluxer.
|
||||
#
|
||||
# Fluxer is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Fluxer is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with Fluxer. If not, see <https://www.gnu.org/licenses/>.";
|
||||
|
||||
const BLOCK_COMMENT_EXTS: &[&str] = &[
|
||||
"ts", "tsx", "js", "jsx", "mjs", "cjs", "css", "go", "rs", "c", "cc", "cpp", "cxx", "h", "hh",
|
||||
"hpp", "hxx", "mm", "m", "java", "kt", "kts", "swift", "scala", "dart", "cs", "fs",
|
||||
];
|
||||
|
||||
const HASH_LINE_EXTS: &[&str] = &[
|
||||
"sh", "bash", "zsh", "py", "rb", "ps1", "psm1", "psd1", "ksh", "fish",
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum HeaderStyle {
|
||||
Block,
|
||||
Line(&'static str),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct FileTemplate {
|
||||
header: &'static str,
|
||||
style: HeaderStyle,
|
||||
}
|
||||
|
||||
impl FileTemplate {
|
||||
const fn new(header: &'static str, style: HeaderStyle) -> Self {
|
||||
Self { header, style }
|
||||
}
|
||||
}
|
||||
|
||||
struct Processor {
|
||||
current_year: i32,
|
||||
updated: usize,
|
||||
ignore_patterns: Vec<String>,
|
||||
}
|
||||
|
||||
impl Processor {
|
||||
fn new() -> Self {
|
||||
let current_year = chrono::Datelike::year(&chrono::Utc::now());
|
||||
let mut processor = Processor {
|
||||
current_year,
|
||||
updated: 0,
|
||||
ignore_patterns: Vec::new(),
|
||||
};
|
||||
processor.load_gitignore();
|
||||
processor
|
||||
}
|
||||
|
||||
fn load_gitignore(&mut self) {
|
||||
if let Ok(file) = fs::File::open(".gitignore") {
|
||||
let reader = BufReader::new(file);
|
||||
for line in reader.lines().map_while(Result::ok) {
|
||||
let trimmed = line.trim();
|
||||
if !trimmed.is_empty() && !trimmed.starts_with('#') {
|
||||
self.ignore_patterns.push(trimmed.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn should_ignore(&self, path: &str) -> bool {
|
||||
if path.contains("fluxer_static") {
|
||||
return true;
|
||||
}
|
||||
for pattern in &self.ignore_patterns {
|
||||
if self.match_pattern(pattern, path) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn match_pattern(&self, pattern: &str, path: &str) -> bool {
|
||||
if let Some(sub_pattern) = pattern.strip_prefix("**/") {
|
||||
if sub_pattern.ends_with('/') {
|
||||
let dir_name = sub_pattern.trim_end_matches('/');
|
||||
return path
|
||||
.split(std::path::MAIN_SEPARATOR)
|
||||
.any(|part| part == dir_name);
|
||||
}
|
||||
return path
|
||||
.split(std::path::MAIN_SEPARATOR)
|
||||
.any(|part| part == sub_pattern);
|
||||
}
|
||||
|
||||
if pattern.ends_with('/') {
|
||||
let dir_pattern = pattern.trim_end_matches('/');
|
||||
return path
|
||||
.split(std::path::MAIN_SEPARATOR)
|
||||
.any(|part| part == dir_pattern)
|
||||
|| path.starts_with(&format!("{dir_pattern}/"));
|
||||
}
|
||||
|
||||
if let Some(p) = pattern.strip_prefix('/') {
|
||||
return path == p;
|
||||
}
|
||||
|
||||
path.split(std::path::MAIN_SEPARATOR)
|
||||
.any(|part| part == pattern)
|
||||
|| Path::new(path).file_name().and_then(|f| f.to_str()) == Some(pattern)
|
||||
}
|
||||
|
||||
fn is_target_file(&self, path: &Path) -> bool {
|
||||
self.get_template(path).is_some()
|
||||
}
|
||||
|
||||
fn get_template(&self, path: &Path) -> Option<FileTemplate> {
|
||||
path.extension()
|
||||
.and_then(|ext| ext.to_str())
|
||||
.and_then(Self::template_for_extension)
|
||||
}
|
||||
|
||||
fn template_for_extension(ext: &str) -> Option<FileTemplate> {
|
||||
let normalized = ext.to_ascii_lowercase();
|
||||
if BLOCK_COMMENT_EXTS.contains(&normalized.as_str()) {
|
||||
Some(FileTemplate::new(TS_LICENSE_HEADER, HeaderStyle::Block))
|
||||
} else if HASH_LINE_EXTS.contains(&normalized.as_str()) {
|
||||
Some(FileTemplate::new(
|
||||
SHELL_LICENSE_HEADER,
|
||||
HeaderStyle::Line("#"),
|
||||
))
|
||||
} else {
|
||||
match normalized.as_str() {
|
||||
"gleam" => Some(FileTemplate::new(
|
||||
GLEAM_LICENSE_HEADER,
|
||||
HeaderStyle::Line("////"),
|
||||
)),
|
||||
"erl" | "hrl" => Some(FileTemplate::new(
|
||||
ERLANG_LICENSE_HEADER,
|
||||
HeaderStyle::Line("%%"),
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_license(&self, content: &str) -> (bool, Option<i32>) {
|
||||
let lines: Vec<&str> = content.lines().take(25).collect();
|
||||
let mut has_agpl = false;
|
||||
let mut has_fluxer = false;
|
||||
let mut detected_year = None;
|
||||
|
||||
let year_regex = Regex::new(r"\b(20\d{2})\b").unwrap();
|
||||
|
||||
for line in lines {
|
||||
let lower = line.to_lowercase();
|
||||
if lower.contains("gnu affero general public license") || lower.contains("agpl") {
|
||||
has_agpl = true;
|
||||
}
|
||||
if lower.contains("fluxer") {
|
||||
has_fluxer = true;
|
||||
}
|
||||
if lower.contains("copyright")
|
||||
&& lower.contains("fluxer")
|
||||
&& detected_year.is_none()
|
||||
&& let Some(cap) = year_regex.captures(line)
|
||||
&& let Ok(year) = cap[1].parse::<i32>()
|
||||
&& (1900..3000).contains(&year)
|
||||
{
|
||||
detected_year = Some(year);
|
||||
}
|
||||
}
|
||||
|
||||
(has_agpl && has_fluxer, detected_year)
|
||||
}
|
||||
|
||||
fn update_year(&self, content: &str, old_year: i32) -> String {
|
||||
content.replacen(&old_year.to_string(), &self.current_year.to_string(), 1)
|
||||
}
|
||||
|
||||
fn strip_license_header(&self, content: &str, style: HeaderStyle) -> (String, bool) {
|
||||
let lines: Vec<&str> = content.split('\n').collect();
|
||||
if lines.is_empty() {
|
||||
return (content.to_string(), false);
|
||||
}
|
||||
|
||||
let mut prefix_end = 0;
|
||||
if let Some(first) = lines.get(0) {
|
||||
if first.starts_with("#!") {
|
||||
prefix_end = 1;
|
||||
}
|
||||
}
|
||||
|
||||
let mut header_start = prefix_end;
|
||||
while header_start < lines.len() && lines[header_start].trim().is_empty() {
|
||||
header_start += 1;
|
||||
}
|
||||
|
||||
if header_start >= lines.len() {
|
||||
return (content.to_string(), false);
|
||||
}
|
||||
|
||||
let original_ending = content.ends_with('\n');
|
||||
|
||||
let after_idx = match style {
|
||||
HeaderStyle::Block => {
|
||||
let first = lines[header_start].trim_start();
|
||||
if !first.starts_with("/*") {
|
||||
return (content.to_string(), false);
|
||||
}
|
||||
let mut header_end = header_start;
|
||||
let mut found_end = false;
|
||||
for i in header_start..lines.len() {
|
||||
if lines[i].contains("*/") {
|
||||
header_end = i;
|
||||
found_end = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !found_end {
|
||||
return (content.to_string(), false);
|
||||
}
|
||||
let mut after = header_end + 1;
|
||||
while after < lines.len() && lines[after].trim().is_empty() {
|
||||
after += 1;
|
||||
}
|
||||
after
|
||||
}
|
||||
HeaderStyle::Line(prefix) => {
|
||||
let first = lines[header_start].trim_start();
|
||||
if !first.starts_with(prefix) {
|
||||
return (content.to_string(), false);
|
||||
}
|
||||
let mut header_end = header_start;
|
||||
while header_end < lines.len() {
|
||||
let trimmed = lines[header_end].trim_start();
|
||||
if trimmed.is_empty() {
|
||||
break;
|
||||
}
|
||||
if trimmed.starts_with(prefix) {
|
||||
header_end += 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
let mut after = header_end;
|
||||
while after < lines.len() && lines[after].trim().is_empty() {
|
||||
after += 1;
|
||||
}
|
||||
after
|
||||
}
|
||||
};
|
||||
|
||||
let mut new_lines = Vec::new();
|
||||
new_lines.extend_from_slice(&lines[..prefix_end]);
|
||||
new_lines.extend_from_slice(&lines[after_idx..]);
|
||||
|
||||
let mut result = new_lines.join("\n");
|
||||
if original_ending && !result.ends_with('\n') {
|
||||
result.push('\n');
|
||||
}
|
||||
|
||||
(result, true)
|
||||
}
|
||||
|
||||
fn add_header(&self, content: &str, template: FileTemplate) -> String {
|
||||
let header = template
|
||||
.header
|
||||
.replace("{year}", &self.current_year.to_string());
|
||||
|
||||
if let Some(first_line) = content.lines().next()
|
||||
&& first_line.starts_with("#!")
|
||||
{
|
||||
let rest = content.lines().skip(1).collect::<Vec<_>>().join("\n");
|
||||
return format!("{first_line}\n\n{header}\n\n{rest}");
|
||||
}
|
||||
|
||||
format!("{header}\n\n{content}")
|
||||
}
|
||||
|
||||
fn process_file(&mut self, path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let content = fs::read_to_string(path)?;
|
||||
let template = self.get_template(path).ok_or("Unknown file type")?;
|
||||
let (has_header, detected_year) = self.detect_license(&content);
|
||||
|
||||
let (new_content, action) = if !has_header {
|
||||
(self.add_header(&content, template), "Added header")
|
||||
} else {
|
||||
let (stripped, stripped_ok) = self.strip_license_header(&content, template.style);
|
||||
if stripped_ok {
|
||||
(self.add_header(&stripped, template), "Normalized header")
|
||||
} else if let Some(old_year) = detected_year {
|
||||
if old_year == self.current_year {
|
||||
return Ok(());
|
||||
}
|
||||
(
|
||||
self.update_year(&content, old_year),
|
||||
&format!("Updated year {} → {}", old_year, self.current_year) as &str,
|
||||
)
|
||||
} else {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
fs::write(path, new_content)?;
|
||||
self.updated += 1;
|
||||
println!("{}: {}", action, path.display());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn walk(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let paths: Vec<PathBuf> = WalkDir::new(".")
|
||||
.into_iter()
|
||||
.filter_map(std::result::Result::ok)
|
||||
.filter(|e| {
|
||||
let path = e.path();
|
||||
let path_str = path.to_string_lossy();
|
||||
!self.should_ignore(&path_str)
|
||||
&& e.file_type().is_file()
|
||||
&& self.is_target_file(path)
|
||||
})
|
||||
.map(|e| e.path().to_path_buf())
|
||||
.collect();
|
||||
|
||||
for path in paths {
|
||||
if let Err(e) = self.process_file(&path) {
|
||||
eprintln!("Error processing {path:?}: {e}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut processor = Processor::new();
|
||||
if let Err(e) = processor.walk() {
|
||||
eprintln!("Error: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
println!("Updated {} files", processor.updated);
|
||||
}
|
||||
251
scripts/snowflake-generator/Cargo.lock
generated
Normal file
251
scripts/snowflake-generator/Cargo.lock
generated
Normal file
@@ -0,0 +1,251 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snowflake-generator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.53.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
||||
13
scripts/snowflake-generator/Cargo.toml
Normal file
13
scripts/snowflake-generator/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "snowflake-generator"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
opt-level = "z"
|
||||
72
scripts/snowflake-generator/src/main.rs
Normal file
72
scripts/snowflake-generator/src/main.rs
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use clap::Parser;
|
||||
use std::thread;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
const FLUXER_EPOCH: i64 = 1420070400000;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "snowflake-generator")]
|
||||
#[command(about = "Generates unique Fluxer snowflake IDs", long_about = None)]
|
||||
struct Cli {
|
||||
/// Number of snowflakes to generate
|
||||
#[arg(long, short, default_value = "1")]
|
||||
count: usize,
|
||||
|
||||
/// Optional Unix timestamp in milliseconds (defaults to current time)
|
||||
#[arg(long, short)]
|
||||
timestamp: Option<i64>,
|
||||
}
|
||||
|
||||
fn generate_snowflake(timestamp: Option<i64>) -> i64 {
|
||||
let ts = match timestamp {
|
||||
Some(t) => t,
|
||||
None => SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis() as i64,
|
||||
};
|
||||
|
||||
(ts - FLUXER_EPOCH) << 22
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
if cli.count < 1 {
|
||||
eprintln!("Error: count must be at least 1");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
if cli.count == 1 {
|
||||
let snowflake = generate_snowflake(cli.timestamp);
|
||||
println!("{snowflake}");
|
||||
} else {
|
||||
for _ in 0..cli.count {
|
||||
let snowflake = generate_snowflake(cli.timestamp);
|
||||
println!("{snowflake}");
|
||||
|
||||
if cli.timestamp.is_none() {
|
||||
thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
tests/integration/Dockerfile
Normal file
22
tests/integration/Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
FROM golang:1.25.5
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
ca-certificates coreutils && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN ls -la tests/integration/fixtures/ || echo "No fixtures found"
|
||||
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
# Pre-compile tests to fail early on build errors and speed up runtime
|
||||
RUN go test -c -o integration.test -v ./tests/integration
|
||||
|
||||
CMD ["sh", "-c", "echo 'Starting integration tests...' && stdbuf -oL -eL ./integration.test -test.v -test.count=1 -test.timeout=0"]
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccountDeleteAutoCancelOnLogin(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
resp, err := client.postJSONWithAuth("/users/@me/delete", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to delete account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, 204)
|
||||
|
||||
loginResp := loginTestUser(t, client, account.Email, account.Password)
|
||||
if loginResp.Token == "" {
|
||||
t.Fatal("expected to be able to login")
|
||||
}
|
||||
|
||||
dataResp, err := client.get("/test/users/" + loginResp.UserID + "/data-exists")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check user data: %v", err)
|
||||
}
|
||||
defer dataResp.Body.Close()
|
||||
|
||||
var dataExists userDataExistsResponse
|
||||
decodeJSONResponse(t, dataResp, &dataExists)
|
||||
|
||||
if dataExists.HasSelfDeletedFlag {
|
||||
t.Error("expected SELF_DELETED flag to be removed after login")
|
||||
}
|
||||
|
||||
if dataExists.PendingDeletionAt != nil {
|
||||
t.Error("expected pending_deletion_at to be cleared after login")
|
||||
}
|
||||
|
||||
t.Log("Auto-cancel deletion on login test passed")
|
||||
}
|
||||
86
tests/integration/account_delete_grace_period_test.go
Normal file
86
tests/integration/account_delete_grace_period_test.go
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccountDeleteGracePeriod(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
resp, err := client.postJSONWithAuth("/users/@me/delete", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to delete account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, 204)
|
||||
|
||||
resp, err = client.getWithAuth("/users/@me", account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get user: %v", err)
|
||||
}
|
||||
if resp.StatusCode != 401 {
|
||||
t.Errorf("expected old token to be invalid (401), got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
dataResp, err := client.get("/test/users/" + account.UserID + "/data-exists")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check user data before login: %v", err)
|
||||
}
|
||||
defer dataResp.Body.Close()
|
||||
|
||||
var dataExistsBeforeLogin userDataExistsResponse
|
||||
decodeJSONResponse(t, dataResp, &dataExistsBeforeLogin)
|
||||
|
||||
if !dataExistsBeforeLogin.HasSelfDeletedFlag {
|
||||
t.Error("expected SELF_DELETED flag to be set before login")
|
||||
}
|
||||
|
||||
if dataExistsBeforeLogin.PendingDeletionAt == nil {
|
||||
t.Error("expected pending_deletion_at to be set before login")
|
||||
}
|
||||
|
||||
loginResp := loginTestUser(t, client, account.Email, account.Password)
|
||||
if loginResp.Token == "" {
|
||||
t.Fatal("expected to be able to login during grace period")
|
||||
}
|
||||
|
||||
dataRespAfterLogin, err := client.get("/test/users/" + loginResp.UserID + "/data-exists")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check user data after login: %v", err)
|
||||
}
|
||||
defer dataRespAfterLogin.Body.Close()
|
||||
|
||||
var dataExistsAfterLogin userDataExistsResponse
|
||||
decodeJSONResponse(t, dataRespAfterLogin, &dataExistsAfterLogin)
|
||||
|
||||
if dataExistsAfterLogin.HasSelfDeletedFlag {
|
||||
t.Error("expected SELF_DELETED flag to be cleared after login")
|
||||
}
|
||||
|
||||
if dataExistsAfterLogin.PendingDeletionAt != nil {
|
||||
t.Error("expected pending_deletion_at to be cleared after login")
|
||||
}
|
||||
|
||||
t.Log("Account deletion grace period test passed")
|
||||
}
|
||||
106
tests/integration/account_delete_message_pagination_test.go
Normal file
106
tests/integration/account_delete_message_pagination_test.go
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAccountDeleteAnonymizesMessagesBeyondChunkSize(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
guild := createGuild(t, client, account.Token, "Message Pagination Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
guildID := parseSnowflake(t, guild.ID)
|
||||
|
||||
const (
|
||||
chunkSize = 100
|
||||
extraMessages = 5
|
||||
)
|
||||
totalMessages := chunkSize + extraMessages
|
||||
|
||||
for i := 0; i < totalMessages; i++ {
|
||||
sendChannelMessage(t, client, account.Token, channelID, fmt.Sprintf("Message %d", i+1))
|
||||
}
|
||||
|
||||
newOwner := createTestAccount(t, client)
|
||||
invite := createChannelInvite(t, client, account.Token, channelID)
|
||||
joinGuild(t, client, newOwner.Token, invite.Code)
|
||||
|
||||
resp, err := client.postJSONWithAuth(
|
||||
fmt.Sprintf("/guilds/%d/transfer-ownership", guildID),
|
||||
map[string]string{
|
||||
"new_owner_id": newOwner.UserID,
|
||||
"password": account.Password,
|
||||
},
|
||||
account.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to transfer guild ownership: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
resp.Body.Close()
|
||||
|
||||
guildResp, err := client.getWithAuth(fmt.Sprintf("/guilds/%d", guildID), account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get guild after transfer: %v", err)
|
||||
}
|
||||
assertStatus(t, guildResp, http.StatusOK)
|
||||
var guildRespBody struct {
|
||||
OwnerID string `json:"owner_id"`
|
||||
}
|
||||
decodeJSONResponse(t, guildResp, &guildRespBody)
|
||||
if guildRespBody.OwnerID != newOwner.UserID {
|
||||
t.Fatalf("expected guild owner to be %s, got %s", newOwner.UserID, guildRespBody.OwnerID)
|
||||
}
|
||||
guildResp.Body.Close()
|
||||
|
||||
resp, err = client.postJSONWithAuth("/users/@me/delete", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to delete account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusNoContent)
|
||||
resp.Body.Close()
|
||||
|
||||
setPendingDeletionAt(t, client, account.UserID, time.Now().Add(-time.Minute))
|
||||
|
||||
triggerDeletionWorker(t, client)
|
||||
waitForDeletionCompletion(t, client, account.UserID, 60*time.Second)
|
||||
|
||||
countResp, err := client.get(fmt.Sprintf("/test/users/%s/messages/count", account.UserID))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to fetch message count: %v", err)
|
||||
}
|
||||
assertStatus(t, countResp, http.StatusOK)
|
||||
var response struct {
|
||||
Count int `json:"count"`
|
||||
}
|
||||
decodeJSONResponse(t, countResp, &response)
|
||||
|
||||
if response.Count != 0 {
|
||||
t.Fatalf("expected 0 remaining messages after anonymization, got %d", response.Count)
|
||||
}
|
||||
}
|
||||
51
tests/integration/account_delete_permanent_test.go
Normal file
51
tests/integration/account_delete_permanent_test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAccountDeletePermanent(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
friend := createTestAccount(t, client)
|
||||
createFriendship(t, client, account, friend)
|
||||
|
||||
resp, err := client.postJSONWithAuth("/users/@me/delete", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to delete account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, 204)
|
||||
|
||||
setPendingDeletionAt(t, client, account.UserID, time.Now().Add(-time.Minute))
|
||||
|
||||
triggerDeletionWorker(t, client)
|
||||
|
||||
waitForDeletionCompletion(t, client, account.UserID, 60*time.Second)
|
||||
|
||||
verifyUserDataDeleted(t, client, account.UserID)
|
||||
|
||||
t.Log("Permanent account deletion test passed")
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccountDisableAutoCancelOnLogin(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
resp, err := client.postJSONWithAuth("/users/@me/disable", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to disable account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusNoContent)
|
||||
resp.Body.Close()
|
||||
|
||||
loginResp := loginTestUser(t, client, account.Email, account.Password)
|
||||
if loginResp.Token == "" {
|
||||
t.Fatal("expected to be able to login")
|
||||
}
|
||||
|
||||
resp, err = client.getWithAuth("/users/@me", loginResp.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get user: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
resp.Body.Close()
|
||||
|
||||
_ = parseSnowflake(t, loginResp.UserID)
|
||||
otherUser := createTestAccount(t, client)
|
||||
otherUserID := parseSnowflake(t, otherUser.UserID)
|
||||
|
||||
guild := createGuild(t, client, loginResp.Token, "Test Guild")
|
||||
invite := createChannelInvite(t, client, loginResp.Token, parseSnowflake(t, guild.SystemChannel))
|
||||
joinGuild(t, client, otherUser.Token, invite.Code)
|
||||
|
||||
dmChannel := createDmChannel(t, client, loginResp.Token, otherUserID)
|
||||
dmChannelID := parseSnowflake(t, dmChannel.ID)
|
||||
message := sendChannelMessage(t, client, loginResp.Token, dmChannelID, "test message")
|
||||
|
||||
if message.ID == "" {
|
||||
t.Error("expected to be able to send messages after auto-undisable")
|
||||
}
|
||||
|
||||
t.Log("Auto-undisable on login test passed")
|
||||
}
|
||||
80
tests/integration/account_disable_test.go
Normal file
80
tests/integration/account_disable_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAccountDisable(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
account := createTestAccount(t, client)
|
||||
|
||||
friend := createTestAccount(t, client)
|
||||
createFriendship(t, client, account, friend)
|
||||
|
||||
resp, err := client.postJSONWithAuth("/users/@me/disable", map[string]string{
|
||||
"password": account.Password,
|
||||
}, account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to disable account: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusNoContent)
|
||||
resp.Body.Close()
|
||||
|
||||
resp, err = client.getWithAuth("/users/@me", account.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get user: %v", err)
|
||||
}
|
||||
if resp.StatusCode != http.StatusUnauthorized {
|
||||
t.Errorf("expected old token to be invalid (401), got %d", resp.StatusCode)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
||||
loginResp := loginTestUser(t, client, account.Email, account.Password)
|
||||
if loginResp.Token == "" {
|
||||
t.Fatal("expected to be able to login after disable")
|
||||
}
|
||||
|
||||
dataResp, err := client.get(fmt.Sprintf("/test/users/%s/data-exists", loginResp.UserID))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check user data: %v", err)
|
||||
}
|
||||
defer dataResp.Body.Close()
|
||||
|
||||
var dataExists userDataExistsResponse
|
||||
decodeJSONResponse(t, dataResp, &dataExists)
|
||||
|
||||
if dataExists.RelationshipsCount == 0 {
|
||||
t.Error("expected relationships to be preserved after disable")
|
||||
}
|
||||
|
||||
if dataExists.EmailCleared {
|
||||
t.Error("expected email to be preserved after disable")
|
||||
}
|
||||
|
||||
if dataExists.PasswordCleared {
|
||||
t.Error("expected password to be preserved after disable")
|
||||
}
|
||||
|
||||
t.Log("Account disable test passed")
|
||||
}
|
||||
50
tests/integration/add_recipient_permissions_test.go
Normal file
50
tests/integration/add_recipient_permissions_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAddRecipientPermissions(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user1 := createTestAccount(t, client)
|
||||
user2 := createTestAccount(t, client)
|
||||
user3 := createTestAccount(t, client)
|
||||
user4 := createTestAccount(t, client)
|
||||
|
||||
createFriendship(t, client, user1, user2)
|
||||
createFriendship(t, client, user1, user3)
|
||||
|
||||
groupDmChannel := createGroupDmChannel(t, client, user1.Token, user2.UserID, user3.UserID)
|
||||
|
||||
t.Run("cannot add non-friend", func(t *testing.T) {
|
||||
resp, err := client.putJSONWithAuth(fmt.Sprintf("/channels/%d/recipients/%s", parseSnowflake(t, groupDmChannel.ID), user4.UserID), nil, user1.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send add recipient request: %v", err)
|
||||
}
|
||||
if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusNoContent {
|
||||
t.Fatalf("expected adding non-friend to fail")
|
||||
}
|
||||
resp.Body.Close()
|
||||
})
|
||||
}
|
||||
76
tests/integration/add_recipient_to_group_dm_test.go
Normal file
76
tests/integration/add_recipient_to_group_dm_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAddRecipientToGroupDM(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user1 := createTestAccount(t, client)
|
||||
user2 := createTestAccount(t, client)
|
||||
user3 := createTestAccount(t, client)
|
||||
|
||||
user1Socket := newGatewayClient(t, client, user1.Token)
|
||||
t.Cleanup(user1Socket.Close)
|
||||
user2Socket := newGatewayClient(t, client, user2.Token)
|
||||
t.Cleanup(user2Socket.Close)
|
||||
user3Socket := newGatewayClient(t, client, user3.Token)
|
||||
t.Cleanup(user3Socket.Close)
|
||||
|
||||
createFriendship(t, client, user1, user2)
|
||||
createFriendship(t, client, user1, user3)
|
||||
|
||||
drainRelationshipEvents(t, user1Socket)
|
||||
drainRelationshipEvents(t, user2Socket)
|
||||
drainRelationshipEvents(t, user3Socket)
|
||||
|
||||
dmChannel := createDmChannel(t, client, user1.Token, parseSnowflake(t, user2.UserID))
|
||||
waitForChannelEvent(t, user1Socket, "CHANNEL_CREATE", dmChannel.ID)
|
||||
|
||||
sendChannelMessage(t, client, user1.Token, parseSnowflake(t, dmChannel.ID), "test message")
|
||||
waitForChannelEvent(t, user2Socket, "CHANNEL_CREATE", dmChannel.ID)
|
||||
|
||||
groupDmChannel := createGroupDmChannel(t, client, user1.Token, user2.UserID, user3.UserID)
|
||||
waitForChannelEvent(t, user1Socket, "CHANNEL_CREATE", groupDmChannel.ID)
|
||||
waitForChannelEvent(t, user2Socket, "CHANNEL_CREATE", groupDmChannel.ID)
|
||||
waitForChannelEvent(t, user3Socket, "CHANNEL_CREATE", groupDmChannel.ID)
|
||||
|
||||
resp, err := client.getWithAuth(fmt.Sprintf("/channels/%d", parseSnowflake(t, groupDmChannel.ID)), user3.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get channel as user3: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
var channel struct {
|
||||
ID string `json:"id"`
|
||||
Type int `json:"type"`
|
||||
Recipients []any `json:"recipients"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &channel)
|
||||
if channel.Type != 3 {
|
||||
t.Fatalf("expected channel type to be 3 (GROUP_DM), got %d", channel.Type)
|
||||
}
|
||||
if len(channel.Recipients) != 2 {
|
||||
t.Fatalf("expected 2 recipients in group DM (excluding current user), got %d", len(channel.Recipients))
|
||||
}
|
||||
}
|
||||
56
tests/integration/admin_endpoints_authz_helper.go
Normal file
56
tests/integration/admin_endpoints_authz_helper.go
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func doAdminRequest(t testing.TB, client *testClient, method, path, token string) *http.Response {
|
||||
t.Helper()
|
||||
|
||||
var body *strings.Reader
|
||||
if method == http.MethodGet {
|
||||
body = strings.NewReader("")
|
||||
} else {
|
||||
body = strings.NewReader("{}")
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, client.baseURL+path, body)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build request: %v", err)
|
||||
}
|
||||
|
||||
if method != http.MethodGet {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
client.applyCommonHeaders(req)
|
||||
if token != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
}
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("request failed: %v", err)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
149
tests/integration/admin_endpoints_require_auth_and_acls_test.go
Normal file
149
tests/integration/admin_endpoints_require_auth_and_acls_test.go
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAdminEndpointsRequireAuthAndAcls(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
admin := createTestAccount(t, client)
|
||||
|
||||
setUserACLs(t, client, admin.UserID, []string{"admin:authenticate"})
|
||||
|
||||
redirectURI := "https://example.com/callback"
|
||||
appID, _, _, _ := createOAuth2Application(
|
||||
t,
|
||||
client,
|
||||
admin,
|
||||
fmt.Sprintf("Admin AuthZ %d", time.Now().UnixNano()),
|
||||
[]string{redirectURI},
|
||||
nil,
|
||||
)
|
||||
code, _ := authorizeOAuth2(t, client, admin.Token, appID, redirectURI, []string{"identify"}, "", "", "")
|
||||
token := exchangeOAuth2AuthorizationCode(t, client, appID, "", code, redirectURI, "").AccessToken
|
||||
|
||||
endpoints := []struct {
|
||||
method string
|
||||
path string
|
||||
}{
|
||||
{http.MethodPost, "/admin/reports/list"},
|
||||
{http.MethodGet, "/admin/reports/1"},
|
||||
{http.MethodPost, "/admin/reports/resolve"},
|
||||
{http.MethodPost, "/admin/reports/search"},
|
||||
{http.MethodPost, "/admin/bulk/update-user-flags"},
|
||||
{http.MethodPost, "/admin/bulk/update-guild-features"},
|
||||
{http.MethodPost, "/admin/bulk/add-guild-members"},
|
||||
{http.MethodPost, "/admin/bulk/schedule-user-deletion"},
|
||||
{http.MethodPost, "/admin/guilds/search"},
|
||||
{http.MethodPost, "/admin/users/search"},
|
||||
{http.MethodPost, "/admin/search/refresh-index"},
|
||||
{http.MethodPost, "/admin/search/refresh-status"},
|
||||
{http.MethodPost, "/admin/voice/regions/list"},
|
||||
{http.MethodPost, "/admin/voice/regions/get"},
|
||||
{http.MethodPost, "/admin/voice/regions/create"},
|
||||
{http.MethodPost, "/admin/voice/regions/update"},
|
||||
{http.MethodPost, "/admin/voice/regions/delete"},
|
||||
{http.MethodPost, "/admin/voice/servers/list"},
|
||||
{http.MethodPost, "/admin/voice/servers/get"},
|
||||
{http.MethodPost, "/admin/voice/servers/create"},
|
||||
{http.MethodPost, "/admin/voice/servers/update"},
|
||||
{http.MethodPost, "/admin/voice/servers/delete"},
|
||||
{http.MethodPost, "/admin/pending-verifications/list"},
|
||||
{http.MethodPost, "/admin/pending-verifications/approve"},
|
||||
{http.MethodPost, "/admin/pending-verifications/reject"},
|
||||
{http.MethodPost, "/admin/messages/lookup"},
|
||||
{http.MethodPost, "/admin/messages/lookup-by-attachment"},
|
||||
{http.MethodPost, "/admin/messages/delete"},
|
||||
{http.MethodPost, "/admin/gateway/memory-stats"},
|
||||
{http.MethodPost, "/admin/gateway/reload-all"},
|
||||
{http.MethodGet, "/admin/gateway/stats"},
|
||||
{http.MethodPost, "/admin/audit-logs"},
|
||||
{http.MethodPost, "/admin/audit-logs/search"},
|
||||
{http.MethodPost, "/admin/guilds/lookup"},
|
||||
{http.MethodPost, "/admin/guilds/list-members"},
|
||||
{http.MethodPost, "/admin/guilds/clear-fields"},
|
||||
{http.MethodPost, "/admin/guilds/update-features"},
|
||||
{http.MethodPost, "/admin/guilds/update-name"},
|
||||
{http.MethodPost, "/admin/guilds/update-settings"},
|
||||
{http.MethodPost, "/admin/guilds/transfer-ownership"},
|
||||
{http.MethodPost, "/admin/guilds/update-vanity"},
|
||||
{http.MethodPost, "/admin/guilds/force-add-user"},
|
||||
{http.MethodPost, "/admin/guilds/reload"},
|
||||
{http.MethodPost, "/admin/guilds/shutdown"},
|
||||
{http.MethodPost, "/admin/users/lookup"},
|
||||
{http.MethodPost, "/admin/users/list-guilds"},
|
||||
{http.MethodPost, "/admin/users/disable-mfa"},
|
||||
{http.MethodPost, "/admin/users/clear-fields"},
|
||||
{http.MethodPost, "/admin/users/set-bot-status"},
|
||||
{http.MethodPost, "/admin/users/set-system-status"},
|
||||
{http.MethodPost, "/admin/users/verify-email"},
|
||||
{http.MethodPost, "/admin/users/send-password-reset"},
|
||||
{http.MethodPost, "/admin/users/change-username"},
|
||||
{http.MethodPost, "/admin/users/change-email"},
|
||||
{http.MethodPost, "/admin/users/terminate-sessions"},
|
||||
{http.MethodPost, "/admin/users/temp-ban"},
|
||||
{http.MethodPost, "/admin/users/unban"},
|
||||
{http.MethodPost, "/admin/users/schedule-deletion"},
|
||||
{http.MethodPost, "/admin/users/cancel-deletion"},
|
||||
{http.MethodPost, "/admin/users/set-acls"},
|
||||
{http.MethodPost, "/admin/users/update-flags"},
|
||||
{http.MethodPost, "/admin/users/unlink-phone"},
|
||||
{http.MethodPost, "/admin/users/change-dob"},
|
||||
{http.MethodPost, "/admin/users/update-suspicious-activity-flags"},
|
||||
{http.MethodPost, "/admin/users/disable-suspicious"},
|
||||
{http.MethodPost, "/admin/users/list-sessions"},
|
||||
{http.MethodPost, "/admin/bans/ip/add"},
|
||||
{http.MethodPost, "/admin/bans/ip/remove"},
|
||||
{http.MethodPost, "/admin/bans/ip/check"},
|
||||
{http.MethodPost, "/admin/bans/email/add"},
|
||||
{http.MethodPost, "/admin/bans/email/remove"},
|
||||
{http.MethodPost, "/admin/bans/email/check"},
|
||||
{http.MethodPost, "/admin/bans/phone/add"},
|
||||
{http.MethodPost, "/admin/bans/phone/remove"},
|
||||
{http.MethodPost, "/admin/bans/phone/check"},
|
||||
}
|
||||
|
||||
for _, ep := range endpoints {
|
||||
ep := ep
|
||||
|
||||
t.Run(ep.method+" "+ep.path+" unauthorized", func(t *testing.T) {
|
||||
resp := doAdminRequest(t, client, ep.method, ep.path, "")
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusUnauthorized {
|
||||
t.Fatalf("expected 401 for %s %s without auth, got %d: %s", ep.method, ep.path, resp.StatusCode, readResponseBody(resp))
|
||||
}
|
||||
})
|
||||
|
||||
t.Run(ep.method+" "+ep.path+" missing-acl", func(t *testing.T) {
|
||||
resp := doAdminRequest(t, client, ep.method, ep.path, token)
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusForbidden {
|
||||
t.Fatalf("expected 403 for %s %s with admin:authenticate only, got %d: %s", ep.method, ep.path, resp.StatusCode, readResponseBody(resp))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
129
tests/integration/admin_user_deletion_schedule_minimums_test.go
Normal file
129
tests/integration/admin_user_deletion_schedule_minimums_test.go
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
standardMinimumDays = 60
|
||||
userRequestedDays = 14
|
||||
)
|
||||
|
||||
func TestAdminUserDeletionScheduleMinimums(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
admin := createTestAccount(t, client)
|
||||
setUserACLs(t, client, admin.UserID, []string{"admin:authenticate", "user:delete"})
|
||||
|
||||
t.Run("NonUserRequestedRequiresStandardMinimum", func(t *testing.T) {
|
||||
target := createTestAccount(t, client)
|
||||
scheduleAdminDeletion(t, client, admin.Token, target.UserID, 2, 10)
|
||||
|
||||
requirePendingDurationBetween(
|
||||
t,
|
||||
client,
|
||||
target.UserID,
|
||||
(standardMinimumDays-1)*24*time.Hour,
|
||||
(standardMinimumDays+2)*24*time.Hour,
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("UserRequestedUsesUserMinimum", func(t *testing.T) {
|
||||
target := createTestAccount(t, client)
|
||||
scheduleAdminDeletion(t, client, admin.Token, target.UserID, 1, 5)
|
||||
|
||||
requirePendingDurationBetween(
|
||||
t,
|
||||
client,
|
||||
target.UserID,
|
||||
(userRequestedDays-1)*24*time.Hour,
|
||||
(userRequestedDays+2)*24*time.Hour,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func scheduleAdminDeletion(t testing.TB, client *testClient, token, userID string, reasonCode, days int) {
|
||||
t.Helper()
|
||||
|
||||
payload := map[string]any{
|
||||
"user_id": userID,
|
||||
"reason_code": reasonCode,
|
||||
"days_until_deletion": days,
|
||||
}
|
||||
|
||||
resp, err := client.postJSONWithAuth("/admin/users/schedule-deletion", payload, token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to request admin deletion: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("expected 200 when scheduling deletion, got %d: %s", resp.StatusCode, readResponseBody(resp))
|
||||
}
|
||||
}
|
||||
|
||||
func requirePendingDurationBetween(t testing.TB, client *testClient, userID string, min, max time.Duration) {
|
||||
t.Helper()
|
||||
|
||||
diff := pendingDeletionDuration(t, client, userID)
|
||||
|
||||
if diff < min {
|
||||
t.Fatalf("expected pending deletion at least %s from now, got %s", min, diff)
|
||||
}
|
||||
if diff > max {
|
||||
t.Fatalf("expected pending deletion at most %s from now, got %s", max, diff)
|
||||
}
|
||||
}
|
||||
|
||||
func pendingDeletionDuration(t testing.TB, client *testClient, userID string) time.Duration {
|
||||
t.Helper()
|
||||
|
||||
resp, err := client.get("/test/users/" + userID + "/data-exists")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to fetch user data: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("expected 200 when fetching user data, got %d: %s", resp.StatusCode, readResponseBody(resp))
|
||||
}
|
||||
|
||||
var data userDataExistsResponse
|
||||
decodeJSONResponse(t, resp, &data)
|
||||
|
||||
if data.PendingDeletionAt == nil {
|
||||
t.Fatalf("expected pending_deletion_at to be set, but it was nil")
|
||||
}
|
||||
|
||||
pendingAt, err := time.Parse(time.RFC3339, *data.PendingDeletionAt)
|
||||
if err != nil {
|
||||
t.Fatalf("invalid pending_deletion_at: %v", err)
|
||||
}
|
||||
|
||||
diff := time.Until(pendingAt)
|
||||
if diff < 0 {
|
||||
t.Fatalf("expected pending deletion to be in the future, got %s", diff)
|
||||
}
|
||||
|
||||
return diff
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAdminUsersSetAclsRequiresAclSetUser(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
admin := createTestAccount(t, client)
|
||||
setUserACLs(t, client, admin.UserID, []string{"admin:authenticate", "user:update:flags"})
|
||||
|
||||
target := createTestAccount(t, client)
|
||||
payload := map[string]any{
|
||||
"user_id": target.UserID,
|
||||
"acls": []string{"user:update:flags"},
|
||||
}
|
||||
|
||||
unauthorizedResp, err := client.postJSONWithAuth("/admin/users/set-acls", payload, admin.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to call set-acls without acl:set:user: %v", err)
|
||||
}
|
||||
if unauthorizedResp.StatusCode != http.StatusForbidden {
|
||||
t.Fatalf(
|
||||
"expected 403 when missing acl:set:user, got %d: %s",
|
||||
unauthorizedResp.StatusCode,
|
||||
readResponseBody(unauthorizedResp),
|
||||
)
|
||||
}
|
||||
unauthorizedResp.Body.Close()
|
||||
|
||||
setUserACLs(t, client, admin.UserID, []string{"admin:authenticate", "acl:set:user"})
|
||||
|
||||
authorizedResp, err := client.postJSONWithAuth("/admin/users/set-acls", payload, admin.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to call set-acls with acl:set:user: %v", err)
|
||||
}
|
||||
if authorizedResp.StatusCode != http.StatusOK {
|
||||
t.Fatalf(
|
||||
"expected 200 when acl:set:user is present, got %d: %s",
|
||||
authorizedResp.StatusCode,
|
||||
readResponseBody(authorizedResp),
|
||||
)
|
||||
}
|
||||
authorizedResp.Body.Close()
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAdministratorRoleGrantsChannelAccess(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
owner := createTestAccount(t, client)
|
||||
member := createTestAccount(t, client)
|
||||
|
||||
guild := createGuild(t, client, owner.Token, fmt.Sprintf("Admin Perms Guild %d", time.Now().UnixNano()))
|
||||
guildID := parseSnowflake(t, guild.ID)
|
||||
|
||||
administratorPermission := 1 << 3
|
||||
resp, err := client.patchJSONWithAuth(fmt.Sprintf("/guilds/%d/roles/%d", guildID, guildID), map[string]any{
|
||||
"permissions": fmt.Sprintf("%d", administratorPermission),
|
||||
}, owner.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to update @everyone role: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
resp.Body.Close()
|
||||
|
||||
invite := createChannelInvite(t, client, owner.Token, parseSnowflake(t, guild.SystemChannel))
|
||||
resp, err = client.postJSONWithAuth(fmt.Sprintf("/invites/%s", invite.Code), nil, member.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to accept invite: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
resp.Body.Close()
|
||||
|
||||
memberGateway := newGatewayClient(t, client, member.Token)
|
||||
t.Cleanup(memberGateway.Close)
|
||||
|
||||
guildCreate := memberGateway.WaitForEvent(t, "GUILD_CREATE", 60*time.Second, func(raw json.RawMessage) bool {
|
||||
var payload struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &payload); err != nil {
|
||||
return false
|
||||
}
|
||||
return payload.ID == guild.ID
|
||||
})
|
||||
|
||||
var guildPayload struct {
|
||||
ID string `json:"id"`
|
||||
Channels []json.RawMessage `json:"channels"`
|
||||
}
|
||||
if err := json.Unmarshal(guildCreate.Data, &guildPayload); err != nil {
|
||||
t.Fatalf("failed to decode GUILD_CREATE payload: %v", err)
|
||||
}
|
||||
|
||||
if len(guildPayload.Channels) == 0 {
|
||||
t.Fatalf("expected member with ADMINISTRATOR permission on @everyone role to see channels, but got empty channels array")
|
||||
}
|
||||
|
||||
systemChannelFound := false
|
||||
for _, channelRaw := range guildPayload.Channels {
|
||||
var channel struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if err := json.Unmarshal(channelRaw, &channel); err != nil {
|
||||
continue
|
||||
}
|
||||
if channel.ID == guild.SystemChannel {
|
||||
systemChannelFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !systemChannelFound {
|
||||
t.Fatalf("expected system channel %s to be visible to member with ADMINISTRATOR permission", guild.SystemChannel)
|
||||
}
|
||||
}
|
||||
29
tests/integration/asset_upload_types.go
Normal file
29
tests/integration/asset_upload_types.go
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
// assetVerifyResponse is the response from /test/verify-asset/* endpoints
|
||||
type assetVerifyResponse struct {
|
||||
Hash *string `json:"hash"`
|
||||
S3Key string `json:"s3_key,omitempty"`
|
||||
ExistsInS3 *bool `json:"existsInS3"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
40
tests/integration/asset_upload_verification_guild_banner.go
Normal file
40
tests/integration/asset_upload_verification_guild_banner.go
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// verifyGuildBannerInS3 checks if the guild's banner exists in S3
|
||||
func verifyGuildBannerInS3(t *testing.T, client *testClient, guildID string) assetVerifyResponse {
|
||||
t.Helper()
|
||||
resp, err := client.get(fmt.Sprintf("/test/verify-asset/guild/%s/banner", guildID))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to verify guild banner: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
var result assetVerifyResponse
|
||||
decodeJSONResponse(t, resp, &result)
|
||||
return result
|
||||
}
|
||||
40
tests/integration/asset_upload_verification_guild_icon.go
Normal file
40
tests/integration/asset_upload_verification_guild_icon.go
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// verifyGuildIconInS3 checks if the guild's icon exists in S3
|
||||
func verifyGuildIconInS3(t *testing.T, client *testClient, guildID string) assetVerifyResponse {
|
||||
t.Helper()
|
||||
resp, err := client.get(fmt.Sprintf("/test/verify-asset/guild/%s/icon", guildID))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to verify guild icon: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
var result assetVerifyResponse
|
||||
decodeJSONResponse(t, resp, &result)
|
||||
return result
|
||||
}
|
||||
40
tests/integration/asset_upload_verification_guild_splash.go
Normal file
40
tests/integration/asset_upload_verification_guild_splash.go
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// verifyGuildSplashInS3 checks if the guild's splash exists in S3
|
||||
func verifyGuildSplashInS3(t *testing.T, client *testClient, guildID string) assetVerifyResponse {
|
||||
t.Helper()
|
||||
resp, err := client.get(fmt.Sprintf("/test/verify-asset/guild/%s/splash", guildID))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to verify guild splash: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
var result assetVerifyResponse
|
||||
decodeJSONResponse(t, resp, &result)
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFavoriteMemeAttachmentsNeverHitDecay(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
channelID := parseSnowflake(t, user.UserID)
|
||||
|
||||
resp, err := client.postJSONWithAuth(
|
||||
"/users/@me/memes",
|
||||
map[string]string{"url": favoriteMemeTestImageURL},
|
||||
user.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create favorite meme: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusCreated)
|
||||
|
||||
var meme favoriteMemeResponse
|
||||
decodeJSONResponse(t, resp, &meme)
|
||||
|
||||
resp, err = client.postJSONWithAuth(
|
||||
fmt.Sprintf("/channels/%d/messages", channelID),
|
||||
map[string]any{"favorite_meme_id": meme.ID},
|
||||
user.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send favorite meme message: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var created struct {
|
||||
ID string `json:"id"`
|
||||
Attachments []struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &created)
|
||||
|
||||
if len(created.Attachments) == 0 {
|
||||
t.Fatalf("expected favorite meme message to include attachments")
|
||||
}
|
||||
|
||||
attachmentID := created.Attachments[0].ID
|
||||
|
||||
assertAttachmentDecayRowMissing(t, client, attachmentID, user.Token)
|
||||
|
||||
resp, err = client.getWithAuth(fmt.Sprintf("/channels/%d/messages/%s", channelID, created.ID), user.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to fetch favorite meme message: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
assertAttachmentDecayRowMissing(t, client, attachmentID, user.Token)
|
||||
}
|
||||
|
||||
func assertAttachmentDecayRowMissing(t testing.TB, client *testClient, attachmentID, token string) {
|
||||
t.Helper()
|
||||
|
||||
resp, err := client.getWithAuth(fmt.Sprintf("/test/attachment-decay/%s", attachmentID), token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query attachment decay row: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var payload struct {
|
||||
Row *struct {
|
||||
AttachmentID string `json:"attachment_id"`
|
||||
} `json:"row"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &payload)
|
||||
if payload.Row != nil {
|
||||
t.Fatalf("expected no attachment decay entry for %s", attachmentID)
|
||||
}
|
||||
}
|
||||
128
tests/integration/attachment_decay_referenced_message_test.go
Normal file
128
tests/integration/attachment_decay_referenced_message_test.go
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAttachmentDecayPopulatesReferencedMessage(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
author := createTestAccount(t, client)
|
||||
recipient := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, author.Token)
|
||||
ensureSessionStarted(t, client, recipient.Token)
|
||||
|
||||
createFriendship(t, client, author, recipient)
|
||||
|
||||
channel := createDmChannel(t, client, author.Token, parseSnowflake(t, recipient.UserID))
|
||||
|
||||
originalMessage, originalAttachmentID := sendChannelMessageWithAttachment(
|
||||
t,
|
||||
client,
|
||||
author.Token,
|
||||
parseSnowflake(t, channel.ID),
|
||||
"Original message for reference",
|
||||
"document.pdf",
|
||||
)
|
||||
|
||||
replyPayload := map[string]any{
|
||||
"content": "Reply referencing expired attachment",
|
||||
"message_reference": map[string]any{
|
||||
"message_id": originalMessage.ID,
|
||||
"channel_id": channel.ID,
|
||||
"type": 0,
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := client.postJSONWithAuth(
|
||||
fmt.Sprintf("/channels/%d/messages", parseSnowflake(t, channel.ID)),
|
||||
replyPayload,
|
||||
author.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to post reply: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
var reply messageResponse
|
||||
decodeJSONResponse(t, resp, &reply)
|
||||
|
||||
rows := []map[string]any{
|
||||
{
|
||||
"attachment_id": fmt.Sprintf("%d", originalAttachmentID),
|
||||
"channel_id": channel.ID,
|
||||
"message_id": originalMessage.ID,
|
||||
"expires_at": time.Now().Add(-1 * time.Hour).Format(time.RFC3339Nano),
|
||||
"uploaded_at": time.Now().Add(-2 * time.Hour).Format(time.RFC3339Nano),
|
||||
"last_accessed_at": time.Now().Add(-1 * time.Hour).Format(time.RFC3339Nano),
|
||||
"filename": "expired-reference.bin",
|
||||
"size_bytes": 2048,
|
||||
"cost": 2,
|
||||
"lifetime_days": 1,
|
||||
},
|
||||
}
|
||||
|
||||
resp, err = client.postJSONWithAuth("/test/attachment-decay/rows", map[string]any{"rows": rows}, author.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to seed attachment decay rows: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
resp, err = client.getWithAuth(
|
||||
fmt.Sprintf("/test/messages/%d/%d/with-reference", parseSnowflake(t, channel.ID), parseSnowflake(t, reply.ID)),
|
||||
author.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to fetch message with reference: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var fetched struct {
|
||||
ID string `json:"id"`
|
||||
ReferencedMessage struct {
|
||||
Attachments []struct {
|
||||
ID string `json:"id"`
|
||||
URL *string `json:"url"`
|
||||
Expired *bool `json:"expired"`
|
||||
ExpiresAt *string `json:"expires_at"`
|
||||
} `json:"attachments"`
|
||||
} `json:"referenced_message"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &fetched)
|
||||
|
||||
if len(fetched.ReferencedMessage.Attachments) == 0 {
|
||||
t.Fatalf("expected referenced message to include attachments")
|
||||
}
|
||||
|
||||
for _, attachment := range fetched.ReferencedMessage.Attachments {
|
||||
if attachment.URL != nil {
|
||||
t.Fatalf("expected referenced message attachment to hide url")
|
||||
}
|
||||
if attachment.Expired == nil || !*attachment.Expired {
|
||||
t.Fatalf("expected referenced message attachment to be marked expired")
|
||||
}
|
||||
if attachment.ExpiresAt == nil {
|
||||
t.Fatalf("expected referenced message attachment to include expires_at")
|
||||
}
|
||||
}
|
||||
}
|
||||
152
tests/integration/attachment_decay_snapshot_test.go
Normal file
152
tests/integration/attachment_decay_snapshot_test.go
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAttachmentDecayAppliesToSnapshotClones(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user1 := createTestAccount(t, client)
|
||||
user2 := createTestAccount(t, client)
|
||||
user3 := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user1.Token)
|
||||
ensureSessionStarted(t, client, user2.Token)
|
||||
ensureSessionStarted(t, client, user3.Token)
|
||||
|
||||
createFriendship(t, client, user1, user2)
|
||||
createFriendship(t, client, user1, user3)
|
||||
|
||||
channel1 := createDmChannel(t, client, user1.Token, parseSnowflake(t, user2.UserID))
|
||||
channel2 := createDmChannel(t, client, user1.Token, parseSnowflake(t, user3.UserID))
|
||||
|
||||
originalMessage, _ := sendChannelMessageWithAttachment(
|
||||
t,
|
||||
client,
|
||||
user1.Token,
|
||||
parseSnowflake(t, channel1.ID),
|
||||
"Original with attachment",
|
||||
"yeah.png",
|
||||
)
|
||||
|
||||
forwardPayload := map[string]any{
|
||||
"message_reference": map[string]any{
|
||||
"message_id": originalMessage.ID,
|
||||
"channel_id": channel1.ID,
|
||||
"type": 1,
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := client.postJSONWithAuth(
|
||||
fmt.Sprintf("/channels/%d/messages", parseSnowflake(t, channel2.ID)),
|
||||
forwardPayload,
|
||||
user1.Token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to forward message: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var forwarded messageResponse
|
||||
decodeJSONResponse(t, resp, &forwarded)
|
||||
|
||||
fetchedSnapshots := fetchMessageSnapshots(t, client, user1.Token, parseSnowflake(t, channel2.ID), parseSnowflake(t, forwarded.ID))
|
||||
if len(fetchedSnapshots) == 0 {
|
||||
t.Fatalf("expected forwarded message to contain snapshots")
|
||||
}
|
||||
|
||||
if len(fetchedSnapshots[0].Attachments) == 0 {
|
||||
t.Fatalf("expected snapshot to include attachments")
|
||||
}
|
||||
|
||||
now := time.Now().UTC()
|
||||
rows := []map[string]any{}
|
||||
for _, attachment := range fetchedSnapshots[0].Attachments {
|
||||
rows = append(rows, map[string]any{
|
||||
"attachment_id": attachment.ID,
|
||||
"channel_id": channel2.ID,
|
||||
"message_id": forwarded.ID,
|
||||
"expires_at": now.Add(-1 * time.Hour).Format(time.RFC3339Nano),
|
||||
"uploaded_at": now.Add(-2 * time.Hour).Format(time.RFC3339Nano),
|
||||
"last_accessed_at": now.Add(-1 * time.Hour).Format(time.RFC3339Nano),
|
||||
"filename": "expired-snapshot.bin",
|
||||
"size_bytes": 1024,
|
||||
"cost": 1,
|
||||
"lifetime_days": 1,
|
||||
})
|
||||
}
|
||||
|
||||
resp, err = client.postJSONWithAuth("/test/attachment-decay/rows", map[string]any{"rows": rows}, user1.Token)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to seed attachment decay rows: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
fetchedSnapshots = fetchMessageSnapshots(t, client, user1.Token, parseSnowflake(t, channel2.ID), parseSnowflake(t, forwarded.ID))
|
||||
if len(fetchedSnapshots[0].Attachments) == 0 {
|
||||
t.Fatalf("expected snapshot to include attachments after update")
|
||||
}
|
||||
|
||||
for _, attachment := range fetchedSnapshots[0].Attachments {
|
||||
if attachment.URL != nil {
|
||||
t.Fatalf("expected expired snapshot attachment to hide url")
|
||||
}
|
||||
if attachment.Expired == nil || !*attachment.Expired {
|
||||
t.Fatalf("expected snapshot attachment to be marked expired")
|
||||
}
|
||||
if attachment.ExpiresAt == nil {
|
||||
t.Fatalf("expected snapshot attachment to include expires_at")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type snapshotAttachment struct {
|
||||
ID string `json:"id"`
|
||||
URL *string `json:"url"`
|
||||
Expired *bool `json:"expired"`
|
||||
ExpiresAt *string `json:"expires_at"`
|
||||
}
|
||||
|
||||
type messageSnapshotResponse struct {
|
||||
Attachments []snapshotAttachment `json:"attachments"`
|
||||
}
|
||||
|
||||
func fetchMessageSnapshots(t testing.TB, client *testClient, token string, channelID, messageID int64) []messageSnapshotResponse {
|
||||
t.Helper()
|
||||
|
||||
resp, err := client.getWithAuth(
|
||||
fmt.Sprintf("/channels/%d/messages/%d", channelID, messageID),
|
||||
token,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to fetch message: %v", err)
|
||||
}
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var fetched struct {
|
||||
MessageSnapshots []messageSnapshotResponse `json:"message_snapshots"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &fetched)
|
||||
return fetched.MessageSnapshots
|
||||
}
|
||||
91
tests/integration/attachment_upload_empty_filename_test.go
Normal file
91
tests/integration/attachment_upload_empty_filename_test.go
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_EmptyFilename tests that empty filenames are rejected
|
||||
func TestAttachmentUpload_EmptyFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Empty Filename Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Empty filename test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": ""},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "actualname.txt")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusBadRequest)
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_ExtremelyLongFilename tests that excessively long filenames are rejected
|
||||
func TestAttachmentUpload_ExtremelyLongFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Long Filename Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
longFilename := strings.Repeat("a", 500) + ".txt"
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Long filename test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": longFilename},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", longFilename)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
t.Error("expected extremely long filename to be rejected, but got 200")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_FilenameMismatchBetweenMetadataAndFile tests strict filename matching
|
||||
func TestAttachmentUpload_FilenameMismatchBetweenMetadataAndFile(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Filename Mismatch Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Filename mismatch test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": "expected.txt"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "different.txt")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
}
|
||||
113
tests/integration/attachment_upload_flags_preserved_test.go
Normal file
113
tests/integration/attachment_upload_flags_preserved_test.go
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_FlagsPreserved tests that attachment flags are properly preserved
|
||||
func TestAttachmentUpload_FlagsPreserved(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Flags Preserved Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Flags preservation test",
|
||||
"attachments": []map[string]any{
|
||||
{
|
||||
"id": 0,
|
||||
"filename": "spoiler.png",
|
||||
"flags": 8,
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "spoiler.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Flags int `json:"flags"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Flags != 8 {
|
||||
t.Errorf("expected flags=8 (spoiler), got %d", msgResp.Attachments[0].Flags)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_IDMatching_MissingMetadata tests that when a file is
|
||||
// uploaded but metadata for its ID is missing, the request fails
|
||||
func TestAttachmentUpload_IDMatching_MissingMetadata(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Missing Metadata Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Missing metadata test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": "yeah.png", "description": "Only zero"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[1]", "test.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[1] field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusBadRequest)
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_IDMatching_OrderedFiles tests that files are correctly
|
||||
// matched with their metadata when sent in the natural order (files[0], files[1], etc.)
|
||||
func TestAttachmentUpload_IDMatching_OrderedFiles(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "ID Matching Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
file1Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file2Data, err := fixturesFS.ReadFile("fixtures/thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Ordered files test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": "yeah.png", "description": "First file", "title": "First"},
|
||||
{"id": 1, "filename": "thisisfine.gif", "description": "Second file", "title": "Second"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
file1Writer, err := writer.CreateFormFile("files[0]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[0] field: %v", err)
|
||||
}
|
||||
if _, err := file1Writer.Write(file1Data); err != nil {
|
||||
t.Fatalf("failed to write file1 data: %v", err)
|
||||
}
|
||||
|
||||
file2Writer, err := writer.CreateFormFile("files[1]", "thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[1] field: %v", err)
|
||||
}
|
||||
if _, err := file2Writer.Write(file2Data); err != nil {
|
||||
t.Fatalf("failed to write file2 data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Description string `json:"description"`
|
||||
Title string `json:"title"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 2 {
|
||||
t.Fatalf("expected 2 attachments, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Filename != "yeah.png" {
|
||||
t.Errorf("expected first filename 'yeah.png', got %q", msgResp.Attachments[0].Filename)
|
||||
}
|
||||
if msgResp.Attachments[0].Description != "First file" {
|
||||
t.Errorf("expected first description 'First file', got %q", msgResp.Attachments[0].Description)
|
||||
}
|
||||
if msgResp.Attachments[0].Title != "First" {
|
||||
t.Errorf("expected first title 'First', got %q", msgResp.Attachments[0].Title)
|
||||
}
|
||||
|
||||
if msgResp.Attachments[1].Filename != "thisisfine.gif" {
|
||||
t.Errorf("expected second filename 'thisisfine.gif', got %q", msgResp.Attachments[1].Filename)
|
||||
}
|
||||
if msgResp.Attachments[1].Description != "Second file" {
|
||||
t.Errorf("expected second description 'Second file', got %q", msgResp.Attachments[1].Description)
|
||||
}
|
||||
if msgResp.Attachments[1].Title != "Second" {
|
||||
t.Errorf("expected second title 'Second', got %q", msgResp.Attachments[1].Title)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_IDMatching_ReversedMetadata tests that when metadata IDs
|
||||
// are reversed (id=1, id=0), they still match correctly with files[0] and files[1]
|
||||
func TestAttachmentUpload_IDMatching_ReversedMetadata(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Reversed Metadata Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
file1Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file2Data, err := fixturesFS.ReadFile("fixtures/thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Reversed metadata test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 1, "filename": "thisisfine.gif", "description": "Second file", "title": "GIF"},
|
||||
{"id": 0, "filename": "yeah.png", "description": "First file", "title": "PNG"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
file1Writer, err := writer.CreateFormFile("files[0]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[0] field: %v", err)
|
||||
}
|
||||
if _, err := file1Writer.Write(file1Data); err != nil {
|
||||
t.Fatalf("failed to write file1 data: %v", err)
|
||||
}
|
||||
|
||||
file2Writer, err := writer.CreateFormFile("files[1]", "thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[1] field: %v", err)
|
||||
}
|
||||
if _, err := file2Writer.Write(file2Data); err != nil {
|
||||
t.Fatalf("failed to write file2 data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Description string `json:"description"`
|
||||
Title string `json:"title"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 2 {
|
||||
t.Fatalf("expected 2 attachments, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Filename != "thisisfine.gif" {
|
||||
t.Errorf("expected first filename 'thisisfine.gif' (first in metadata array), got %q", msgResp.Attachments[0].Filename)
|
||||
}
|
||||
if msgResp.Attachments[0].Description != "Second file" {
|
||||
t.Errorf("expected first description 'Second file' (from metadata[0] with id=1), got %q", msgResp.Attachments[0].Description)
|
||||
}
|
||||
if msgResp.Attachments[0].Title != "GIF" {
|
||||
t.Errorf("expected first title 'GIF' (from metadata[0] with id=1), got %q", msgResp.Attachments[0].Title)
|
||||
}
|
||||
|
||||
if msgResp.Attachments[1].Filename != "yeah.png" {
|
||||
t.Errorf("expected second filename 'yeah.png' (second in metadata array), got %q", msgResp.Attachments[1].Filename)
|
||||
}
|
||||
if msgResp.Attachments[1].Description != "First file" {
|
||||
t.Errorf("expected second description 'First file' (from metadata[1] with id=0), got %q", msgResp.Attachments[1].Description)
|
||||
}
|
||||
if msgResp.Attachments[1].Title != "PNG" {
|
||||
t.Errorf("expected second title 'PNG' (from metadata[1] with id=0), got %q", msgResp.Attachments[1].Title)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_IDMatching_SparseIDs tests using non-sequential IDs like 2, 5
|
||||
func TestAttachmentUpload_IDMatching_SparseIDs(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Sparse IDs Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
file1Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file2Data, err := fixturesFS.ReadFile("fixtures/thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Sparse IDs test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 2, "filename": "yeah.png", "description": "ID is 2", "title": "Two"},
|
||||
{"id": 5, "filename": "thisisfine.gif", "description": "ID is 5", "title": "Five"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
file1Writer, err := writer.CreateFormFile("files[2]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[2] field: %v", err)
|
||||
}
|
||||
if _, err := file1Writer.Write(file1Data); err != nil {
|
||||
t.Fatalf("failed to write file1 data: %v", err)
|
||||
}
|
||||
|
||||
file2Writer, err := writer.CreateFormFile("files[5]", "thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[5] field: %v", err)
|
||||
}
|
||||
if _, err := file2Writer.Write(file2Data); err != nil {
|
||||
t.Fatalf("failed to write file2 data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Description string `json:"description"`
|
||||
Title string `json:"title"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 2 {
|
||||
t.Fatalf("expected 2 attachments, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Description != "ID is 2" {
|
||||
t.Errorf("expected first description 'ID is 2', got %q", msgResp.Attachments[0].Description)
|
||||
}
|
||||
if msgResp.Attachments[0].Title != "Two" {
|
||||
t.Errorf("expected first title 'Two', got %q", msgResp.Attachments[0].Title)
|
||||
}
|
||||
|
||||
if msgResp.Attachments[1].Description != "ID is 5" {
|
||||
t.Errorf("expected second description 'ID is 5', got %q", msgResp.Attachments[1].Description)
|
||||
}
|
||||
if msgResp.Attachments[1].Title != "Five" {
|
||||
t.Errorf("expected second title 'Five', got %q", msgResp.Attachments[1].Title)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_IDMismatchBetweenMetadataAndFile tests that mismatched IDs are caught
|
||||
func TestAttachmentUpload_IDMismatchBetweenMetadataAndFile(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "ID Mismatch Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "ID mismatch test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 5, "filename": "test.txt"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "test.txt")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusBadRequest)
|
||||
}
|
||||
111
tests/integration/attachment_upload_invalid_filename_test.go
Normal file
111
tests/integration/attachment_upload_invalid_filename_test.go
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_InvalidFilename tests that invalid filenames are rejected
|
||||
func TestAttachmentUpload_InvalidFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Invalid Filename Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
filename string
|
||||
}{
|
||||
{"empty filename", ""},
|
||||
{"filename too long", string(make([]byte, 300))},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Invalid filename test",
|
||||
"attachments": []map[string]any{
|
||||
{
|
||||
"id": 0,
|
||||
"filename": tc.filename,
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", tc.filename)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
t.Error("expected request to fail with invalid filename, but it succeeded")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_MetadataWithoutFile tests providing attachment metadata
|
||||
// but not uploading the corresponding file
|
||||
func TestAttachmentUpload_MetadataWithoutFile(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Metadata Without File Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Metadata without file",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": "missing.png", "description": "This file doesn't exist"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusBadRequest)
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_MultipleFilesWithMixedMetadata tests complex scenario with
|
||||
// multiple files and mixed metadata quality (some with title/desc, some without)
|
||||
func TestAttachmentUpload_MultipleFilesWithMixedMetadata(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Mixed Metadata Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
file1Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file2Data, err := fixturesFS.ReadFile("fixtures/thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Mixed metadata test",
|
||||
"attachments": []map[string]any{
|
||||
{
|
||||
"id": 0,
|
||||
"filename": "yeah.png",
|
||||
"title": "Full Metadata",
|
||||
"description": "Complete description",
|
||||
"flags": 0,
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"filename": "thisisfine.gif",
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
file1Writer, err := writer.CreateFormFile("files[0]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[0] field: %v", err)
|
||||
}
|
||||
if _, err := file1Writer.Write(file1Data); err != nil {
|
||||
t.Fatalf("failed to write file1 data: %v", err)
|
||||
}
|
||||
|
||||
file2Writer, err := writer.CreateFormFile("files[1]", "thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[1] field: %v", err)
|
||||
}
|
||||
if _, err := file2Writer.Write(file2Data); err != nil {
|
||||
t.Fatalf("failed to write file2 data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Title *string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 2 {
|
||||
t.Fatalf("expected 2 attachments, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Title == nil || *msgResp.Attachments[0].Title != "Full Metadata" {
|
||||
t.Error("expected first attachment to have title 'Full Metadata'")
|
||||
}
|
||||
if msgResp.Attachments[0].Description == nil || *msgResp.Attachments[0].Description != "Complete description" {
|
||||
t.Error("expected first attachment to have description 'Complete description'")
|
||||
}
|
||||
|
||||
if msgResp.Attachments[1].Title != nil {
|
||||
t.Errorf("expected second attachment title to be nil, got %q", *msgResp.Attachments[1].Title)
|
||||
}
|
||||
if msgResp.Attachments[1].Description != nil {
|
||||
t.Errorf("expected second attachment description to be nil, got %q", *msgResp.Attachments[1].Description)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_NegativeIDInMetadata tests that negative IDs are rejected
|
||||
func TestAttachmentUpload_NegativeIDInMetadata(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Negative ID Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Negative ID test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": -1, "filename": "test.txt"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "test.txt")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusBadRequest)
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_NullByteInFilename tests that null bytes in filenames are sanitized
|
||||
func TestAttachmentUpload_NullByteInFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Null Byte Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
maliciousFilenames := []string{
|
||||
"innocent.txt\x00.exe",
|
||||
"test\x00.jpg",
|
||||
"file.pdf\x00malicious",
|
||||
"\x00hidden.txt",
|
||||
}
|
||||
|
||||
for _, filename := range maliciousFilenames {
|
||||
t.Run("filename_with_null_byte", func(t *testing.T) {
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Null byte test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": filename},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", filename)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
sanitized := msgResp.Attachments[0].Filename
|
||||
if strings.Contains(sanitized, "\x00") {
|
||||
t.Errorf("sanitized filename still contains null bytes")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
119
tests/integration/attachment_upload_nullable_fields_test.go
Normal file
119
tests/integration/attachment_upload_nullable_fields_test.go
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_NullableFields tests that title and description can be null
|
||||
func TestAttachmentUpload_NullableFields(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Nullable Fields Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Null fields test",
|
||||
"attachments": []map[string]any{
|
||||
{
|
||||
"id": 0,
|
||||
"filename": "yeah.png",
|
||||
"title": nil,
|
||||
"description": nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Title *string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
att := msgResp.Attachments[0]
|
||||
if att.Title != nil {
|
||||
t.Errorf("expected title to be nil, got %q", *att.Title)
|
||||
}
|
||||
if att.Description != nil {
|
||||
t.Errorf("expected description to be nil, got %q", *att.Description)
|
||||
}
|
||||
}
|
||||
118
tests/integration/attachment_upload_omitted_fields_test.go
Normal file
118
tests/integration/attachment_upload_omitted_fields_test.go
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_OmittedFields tests that when title/description are omitted
|
||||
// (not sent at all), they default to null
|
||||
func TestAttachmentUpload_OmittedFields(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Omitted Fields Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Omitted fields test",
|
||||
"attachments": []map[string]any{
|
||||
{
|
||||
"id": 0,
|
||||
"filename": "yeah.png",
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", "yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Title *string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
att := msgResp.Attachments[0]
|
||||
if att.Title != nil {
|
||||
t.Errorf("expected omitted title to be nil, got %q", *att.Title)
|
||||
}
|
||||
if att.Description != nil {
|
||||
t.Errorf("expected omitted description to be nil, got %q", *att.Description)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_OrderingMatchesMetadataArray tests that the final attachment
|
||||
// order in the message matches the order of the attachments array, not the file indices
|
||||
func TestAttachmentUpload_OrderingMatchesMetadataArray(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Ordering Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
file1Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file2Data, err := fixturesFS.ReadFile("fixtures/thisisfine.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
file3Data, err := fixturesFS.ReadFile("fixtures/yeah.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read fixture: %v", err)
|
||||
}
|
||||
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Ordering test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 2, "filename": "third.png", "description": "Should be first"},
|
||||
{"id": 0, "filename": "first.png", "description": "Should be second"},
|
||||
{"id": 1, "filename": "second.gif", "description": "Should be third"},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
file1Writer, err := writer.CreateFormFile("files[0]", "first.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[0] field: %v", err)
|
||||
}
|
||||
if _, err := file1Writer.Write(file1Data); err != nil {
|
||||
t.Fatalf("failed to write file1 data: %v", err)
|
||||
}
|
||||
|
||||
file2Writer, err := writer.CreateFormFile("files[1]", "second.gif")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[1] field: %v", err)
|
||||
}
|
||||
if _, err := file2Writer.Write(file2Data); err != nil {
|
||||
t.Fatalf("failed to write file2 data: %v", err)
|
||||
}
|
||||
|
||||
file3Writer, err := writer.CreateFormFile("files[2]", "third.png")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create files[2] field: %v", err)
|
||||
}
|
||||
if _, err := file3Writer.Write(file3Data); err != nil {
|
||||
t.Fatalf("failed to write file3 data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
Description string `json:"description"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 3 {
|
||||
t.Fatalf("expected 3 attachments, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
if msgResp.Attachments[0].Filename != "third.png" {
|
||||
t.Errorf("expected first attachment filename 'third.png', got %q", msgResp.Attachments[0].Filename)
|
||||
}
|
||||
if msgResp.Attachments[0].Description != "Should be first" {
|
||||
t.Errorf("expected first attachment description 'Should be first', got %q", msgResp.Attachments[0].Description)
|
||||
}
|
||||
|
||||
if msgResp.Attachments[1].Filename != "first.png" {
|
||||
t.Errorf("expected second attachment filename 'first.png', got %q", msgResp.Attachments[1].Filename)
|
||||
}
|
||||
if msgResp.Attachments[1].Description != "Should be second" {
|
||||
t.Errorf("expected second attachment description 'Should be second', got %q", msgResp.Attachments[1].Description)
|
||||
}
|
||||
|
||||
if msgResp.Attachments[2].Filename != "second.gif" {
|
||||
t.Errorf("expected third attachment filename 'second.gif', got %q", msgResp.Attachments[2].Filename)
|
||||
}
|
||||
if msgResp.Attachments[2].Description != "Should be third" {
|
||||
t.Errorf("expected third attachment description 'Should be third', got %q", msgResp.Attachments[2].Description)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_PathTraversalInFilename tests that path traversal attempts in filenames are sanitized
|
||||
func TestAttachmentUpload_PathTraversalInFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Path Traversal Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
testCases := []struct {
|
||||
input string
|
||||
expectedSuffix string
|
||||
}{
|
||||
{"../../../etc/passwd", "passwd"},
|
||||
{"..\\..\\..\\windows\\system32\\config\\sam", "sam"},
|
||||
{"....//....//....//etc/passwd", "passwd"},
|
||||
{"..\\..\\..", ""},
|
||||
{"../../sensitive.txt", "sensitive.txt"},
|
||||
{"./../../etc/hosts", "hosts"},
|
||||
{"foo/../../../bar.txt", "foo_bar.txt"},
|
||||
{"a/b/c/../../../d.txt", "a_b_c_d.txt"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("filename=%s", tc.input), func(t *testing.T) {
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Path traversal test",
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": tc.input},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", tc.input)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
sanitized := msgResp.Attachments[0].Filename
|
||||
if strings.Contains(sanitized, "..") || strings.Contains(sanitized, "/") || strings.Contains(sanitized, "\\") {
|
||||
t.Errorf("sanitized filename %q still contains path traversal characters", sanitized)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestAttachmentUpload_SpecialCharactersInFilename tests handling of special characters
|
||||
func TestAttachmentUpload_SpecialCharactersInFilename(t *testing.T) {
|
||||
client := newTestClient(t)
|
||||
user := createTestAccount(t, client)
|
||||
ensureSessionStarted(t, client, user.Token)
|
||||
|
||||
guild := createGuild(t, client, user.Token, "Special Chars Test Guild")
|
||||
channelID := parseSnowflake(t, guild.SystemChannel)
|
||||
|
||||
fileData := []byte("test content")
|
||||
|
||||
testCases := []struct {
|
||||
filename string
|
||||
shouldBeSanitized bool
|
||||
description string
|
||||
}{
|
||||
{"file<script>.txt", true, "HTML tag in filename"},
|
||||
{"file>output.txt", true, "redirect operator"},
|
||||
{"file|pipe.txt", true, "pipe character"},
|
||||
{"file:colon.txt", true, "colon (Windows reserved)"},
|
||||
{"file*star.txt", true, "asterisk (wildcard)"},
|
||||
{"file?question.txt", true, "question mark"},
|
||||
{"file\"quote.txt", true, "double quote"},
|
||||
{"COM1.txt", true, "Windows reserved name"},
|
||||
{"LPT1.txt", true, "Windows reserved name"},
|
||||
{"file with spaces.txt", false, "spaces should be OK"},
|
||||
{"file-dash_underscore.txt", false, "dash and underscore OK"},
|
||||
{"file.multiple.dots.txt", false, "multiple dots OK"},
|
||||
{"файл.txt", false, "unicode characters OK"},
|
||||
{"文件.txt", false, "CJK characters OK"},
|
||||
{"😀.txt", false, "emoji OK"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
var body bytes.Buffer
|
||||
writer := multipart.NewWriter(&body)
|
||||
|
||||
payload := map[string]any{
|
||||
"content": "Special char test: " + tc.description,
|
||||
"attachments": []map[string]any{
|
||||
{"id": 0, "filename": tc.filename},
|
||||
},
|
||||
}
|
||||
payloadJSON, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode payload JSON: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.WriteField("payload_json", string(payloadJSON)); err != nil {
|
||||
t.Fatalf("failed to write payload_json field: %v", err)
|
||||
}
|
||||
|
||||
safeFilename := "test.txt"
|
||||
fileWriter, err := writer.CreateFormFile("files[0]", safeFilename)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create file field: %v", err)
|
||||
}
|
||||
if _, err := fileWriter.Write(fileData); err != nil {
|
||||
t.Fatalf("failed to write file data: %v", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
t.Fatalf("failed to close multipart writer: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
http.MethodPost,
|
||||
fmt.Sprintf("%s/channels/%d/messages", client.baseURL, channelID),
|
||||
&body,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
client.applyCommonHeaders(req)
|
||||
req.Header.Set("Authorization", user.Token)
|
||||
|
||||
resp, err := client.httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to send request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
assertStatus(t, resp, http.StatusOK)
|
||||
|
||||
var msgResp struct {
|
||||
Attachments []struct {
|
||||
Filename string `json:"filename"`
|
||||
} `json:"attachments"`
|
||||
}
|
||||
decodeJSONResponse(t, resp, &msgResp)
|
||||
|
||||
if len(msgResp.Attachments) != 1 {
|
||||
t.Fatalf("expected 1 attachment, got %d", len(msgResp.Attachments))
|
||||
}
|
||||
|
||||
sanitized := msgResp.Attachments[0].Filename
|
||||
|
||||
if tc.shouldBeSanitized {
|
||||
if strings.ContainsAny(sanitized, "<>:\"|?*") {
|
||||
t.Errorf("sanitized filename %q still contains dangerous characters", sanitized)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user