Compare commits
13 commits
000d2b77c2
...
58d0c69e0b
Author | SHA1 | Date | |
---|---|---|---|
58d0c69e0b | |||
e59d2384e8 | |||
dc4059e9a2 | |||
9c1dfd093d | |||
459f925391 | |||
5bd6ad68e6 | |||
4be1f780a1 | |||
8db3d6b700 | |||
666b8bc4f2 | |||
7c6c74243b | |||
75d3fca08c | |||
bd4c4d79fe | |||
c1543c029b |
12
.drone.yml
|
@ -12,7 +12,7 @@ steps:
|
|||
# We use golangci-lint for linting.
|
||||
# See: https://golangci-lint.run/
|
||||
- name: lint
|
||||
image: golangci/golangci-lint:v1.57.2
|
||||
image: golangci/golangci-lint:v1.60.3
|
||||
volumes:
|
||||
- name: go-build-cache
|
||||
path: /root/.cache/go-build
|
||||
|
@ -28,7 +28,7 @@ steps:
|
|||
- pull_request
|
||||
|
||||
- name: test
|
||||
image: golang:1.22-alpine
|
||||
image: golang:1.23.0-alpine
|
||||
volumes:
|
||||
- name: go-build-cache
|
||||
path: /root/.cache/go-build
|
||||
|
@ -94,7 +94,7 @@ steps:
|
|||
- pull_request
|
||||
|
||||
- name: snapshot
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.6.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.7.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
|
||||
volumes:
|
||||
- name: go-build-cache
|
||||
path: /root/.cache/go-build
|
||||
|
@ -135,7 +135,7 @@ steps:
|
|||
- main
|
||||
|
||||
- name: release
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.6.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.7.0 # https://github.com/superseriousbusiness/gotosocial-drone-build
|
||||
volumes:
|
||||
- name: go-build-cache
|
||||
path: /root/.cache/go-build
|
||||
|
@ -194,7 +194,7 @@ clone:
|
|||
|
||||
steps:
|
||||
- name: mirror
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.6.0
|
||||
image: superseriousbusiness/gotosocial-drone-build:0.7.0
|
||||
environment:
|
||||
ORIGIN_REPO: https://github.com/superseriousbusiness/gotosocial
|
||||
TARGET_REPO: https://codeberg.org/superseriousbusiness/gotosocial
|
||||
|
@ -207,6 +207,6 @@ steps:
|
|||
|
||||
---
|
||||
kind: signature
|
||||
hmac: f4008d87e4e5b67251eb89f255c1224e6ab5818828cab24fc319b8f829176058
|
||||
hmac: 9810bf692fb1029c13b0a1e2f556e2306d16f7d3eec9ca6163a0499c147280c1
|
||||
|
||||
...
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# https://goreleaser.com
|
||||
# Version 2 of GoReleaser: https://goreleaser.com/errors/version/
|
||||
version: 2
|
||||
project_name: gotosocial
|
||||
before:
|
||||
# https://goreleaser.com/customization/hooks/
|
||||
|
@ -185,7 +186,7 @@ checksum:
|
|||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
# https://goreleaser.com/customization/snapshots/
|
||||
name_template: "{{ incpatch .Version }}-SNAPSHOT"
|
||||
version_template: "{{ incpatch .Version }}-SNAPSHOT"
|
||||
source:
|
||||
# https://goreleaser.com/customization/source/
|
||||
enabled: true
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Dockerfile reference: https://docs.docker.com/engine/reference/builder/
|
||||
|
||||
# stage 1: generate up-to-date swagger.yaml to put in the final container
|
||||
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine AS swagger
|
||||
FROM --platform=${BUILDPLATFORM} golang:1.23.0-alpine AS swagger
|
||||
|
||||
RUN \
|
||||
### Installs goswagger for building swagger definitions inside this container
|
||||
|
@ -28,7 +28,7 @@ RUN yarn --cwd ./web/source install && \
|
|||
rm -rf ./web/source
|
||||
|
||||
# stage 3: build the executor container
|
||||
FROM --platform=${TARGETPLATFORM} alpine:3.19.1 as executor
|
||||
FROM --platform=${TARGETPLATFORM} alpine:3.20.2 as executor
|
||||
|
||||
# switch to non-root user:group for GtS
|
||||
USER 1000:1000
|
||||
|
|
120
README.md
|
@ -11,7 +11,7 @@ With GoToSocial, you can keep in touch with your friends, post, read, and share
|
|||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/sloth.webp" width="300"/>
|
||||
</p>
|
||||
|
||||
**GoToSocial is still [ALPHA SOFTWARE](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)**. It is already deployable and useable, and it federates cleanly with many other Fediverse servers (not yet all). However, many things are not yet implemented, and there are plenty of bugs! We foresee entering beta around the beginning of 2024.
|
||||
**GoToSocial is still [BETA SOFTWARE](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta)**. It is already deployable and useable, and it federates cleanly with many other Fediverse servers (not yet all). However, many things are not yet implemented, and there are plenty of bugs! We left alpha stage around September/October 2024, and we intend to exit beta some time around 2026.
|
||||
|
||||
Documentation is at [docs.gotosocial.org](https://docs.gotosocial.org). You can skip straight to the API documentation [here](https://docs.gotosocial.org/en/latest/api/swagger/).
|
||||
|
||||
|
@ -29,8 +29,12 @@ Here's a screenshot of the instance landing page!
|
|||
- [History and Status](#history-and-status)
|
||||
- [Features](#features)
|
||||
- [Mastodon API compatibility](#mastodon-api-compatibility)
|
||||
- [Granular post settings](#granular-post-settings)
|
||||
- [Customizability](#customizability)
|
||||
- [Granular post visibility settings](#granular-post-visibility-settings)
|
||||
- [Reply controls](#reply-controls)
|
||||
- [Local-only posting](#local-only-posting)
|
||||
- [RSS feed](#rss-feed)
|
||||
- [Rich text formatting](#rich-text-formatting)
|
||||
- [Themes and custom CSS](#themes-and-custom-css)
|
||||
- [Easy to run](#easy-to-run)
|
||||
- [Safety + security features](#safety--security-features)
|
||||
- [Various federation modes](#various-federation-modes)
|
||||
|
@ -90,7 +94,9 @@ This project sprang up in February/March 2021 out of a dissatisfaction with the
|
|||
|
||||
It began as a solo project, and then picked up steam as more developers became interested and jumped on.
|
||||
|
||||
For a detailed view on what's implemented and what's not, and progress made towards [beta release](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta), please see [the roadmap document](https://github.com/superseriousbusiness/gotosocial/blob/main/ROADMAP.md).
|
||||
We made our first Alpha release in November 2021. We left Alpha and entered Beta in September/October 2024.
|
||||
|
||||
For a detailed view on what's implemented and what's not, and progress made towards [stable release](https://en.wikipedia.org/wiki/Software_release_life_cycle#Stable_release), please see [the roadmap document](https://github.com/superseriousbusiness/gotosocial/blob/main/ROADMAP.md).
|
||||
|
||||
---
|
||||
|
||||
|
@ -100,44 +106,120 @@ For a detailed view on what's implemented and what's not, and progress made towa
|
|||
|
||||
The Mastodon API has become the de facto standard for client communication with federated servers, so GoToSocial has implemented and extended the API with custom functionality.
|
||||
|
||||
Though most apps that implement the Mastodon API should work, GoToSocial works reliably with beautiful apps like:
|
||||
Though most apps that implement the Mastodon API should work, GoToSocial is tested and works reliably with beautiful apps like:
|
||||
|
||||
* [Tusky](https://tusky.app/) for Android
|
||||
* [Semaphore](https://semaphore.social/) in the browser
|
||||
* [Feditext](https://github.com/feditext/feditext) (beta) on iOS, iPadOS and macOS
|
||||
|
||||
If you've used Mastodon with any of these apps before, you'll find using GoToSocial a breeze.
|
||||
If you've used Mastodon with a third-party app before, you'll find using GoToSocial a breeze.
|
||||
|
||||
### Granular post settings
|
||||
### Granular post visibility settings
|
||||
|
||||
It's important that when you post something, you can choose who sees it.
|
||||
|
||||
GoToSocial offers public/unlisted/friends-only/mutuals-only/and direct posts (slide in DMs! -- with consent).
|
||||
GoToSocial offers public, unlisted/unlocked, followers-only, and direct posts (slide in DMs! -- with consent).
|
||||
|
||||
It also allows you to customize how people interact with your posts:
|
||||
### Reply controls
|
||||
|
||||
- Local-only posts.
|
||||
- Rebloggable/boostable toggle.
|
||||
- 'Likeable' toggle.
|
||||
- 'Replyable' toggle.
|
||||
GoToSocial lets you choose who can reply to your posts, via [interaction policies](https://docs.gotosocial.org/en/latest/user_guide/settings/#default-interaction-policies). You can choose to let anyone reply to your posts, let only your friends reply, and more.
|
||||
|
||||
### Customizability
|
||||
![interaction policies settings](https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/user-settings-interaction-policy-1.png)
|
||||
|
||||
### Local-only posting
|
||||
|
||||
Sometimes you only want to talk to people you share an instance with. GoToSocial supports this via local-only posting, which ensures that your post stays on your instance only. (Local-only posting is currently dependent on client support.)
|
||||
|
||||
### RSS feed
|
||||
|
||||
GoToSocial lets you opt-in to exposing your profile as an RSS feed, so that people can subscribe to your public feed without missing a post.
|
||||
|
||||
### Rich text formatting
|
||||
|
||||
With GoToSocial, you can write posts using the popular, easy-to-use Markdown markup language, which lets you produce rich HTML posts with support for blockquotes, syntax-highlighted code blocks, lists, inline links, and more.
|
||||
|
||||
![markdown-formatted post](https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/markdown-post.png)
|
||||
|
||||
### Themes and custom CSS
|
||||
|
||||
Users can [choose from a variety of fun themes](https://docs.gotosocial.org/en/latest/user_guide/settings/#select-theme) for their profile, or even write their own [custom CSS](https://docs.gotosocial.org/en/latest/user_guide/settings/#custom-css).
|
||||
|
||||
Plenty of [config options](https://github.com/superseriousbusiness/gotosocial/blob/main/example/config.yaml) for admins to play around with too.
|
||||
It's also easy for admins to [add their own custom themes](https://docs.gotosocial.org/en/latest/admin/themes/) for users to choose from.
|
||||
|
||||
<details>
|
||||
<summary>Show theme examples</summary>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-blurple-dark.png"/>
|
||||
<figcaption>Blurple dark</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-blurple-light.png"/>
|
||||
<figcaption>Blurple light</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-brutalist-light.png"/>
|
||||
<figcaption>Brutalist light</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-brutalist-dark.png"/>
|
||||
<figcaption>Brutalist dark</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-ecks-pee.png"/>
|
||||
<figcaption>Ecks pee</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-midnight-trip.png"/>
|
||||
<figcaption>Midnight trip</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-rainforest.png"/>
|
||||
<figcaption>Rainforest</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-soft.png"/>
|
||||
<figcaption>Soft</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-solarized-dark.png"/>
|
||||
<figcaption>Solarized dark</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-solarized-light.png"/>
|
||||
<figcaption>Solarized light</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
<figure>
|
||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-sunset.png"/>
|
||||
<figcaption>Sunset</figcaption>
|
||||
</figure>
|
||||
<hr/>
|
||||
</details>
|
||||
|
||||
### Easy to run
|
||||
|
||||
No external dependencies apart from a database (or just use SQLite!). Simply download the binary + assets (or Docker container), and run.
|
||||
GoToSocial uses only about 250-350MiB of RAM, and requires very little CPU power, so it plays nice with single-board computers, old laptops and tiny $5/month VPSes.
|
||||
|
||||
GoToSocial uses only about 150-250MiB of RAM, so it plays nice with single-board computers, old laptops and tiny $5/month VPSes.
|
||||
![Grafana graph showing GoToSocial heap in use hovering around 250MB and spiking occasionally to 400MB-500MB.](https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/getting-started-memory-graph.png)
|
||||
|
||||
No external dependencies apart from a database (or just use SQLite!).
|
||||
|
||||
Simply download the binary + assets (or Docker container), tweak your configuration, and run.
|
||||
|
||||
### Safety + security features
|
||||
|
||||
- Built-in, automatic support for secure HTTPS with [Let's Encrypt](https://letsencrypt.org/).
|
||||
- Strict privacy enforcement for posts and strict blocking logic.
|
||||
- Import and export allow lists and deny lists. Subscribe to community-created block lists (think Ad blocker, but for federation!).
|
||||
- Import and export allow lists and deny lists. Subscribe to community-created block lists (think Ad blocker, but for federation!) (feature still in progress).
|
||||
- HTTP signature authentication: GoToSocial requires [HTTP Signatures](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12) when sending and receiving messages, to ensure that your messages can't be tampered with and your identity can't be forged.
|
||||
|
||||
### Various federation modes
|
||||
|
@ -166,7 +248,7 @@ On top of this API, web developers are encouraged to build any front-end impleme
|
|||
|
||||
## Known Issues
|
||||
|
||||
Since GoToSocial is still in alpha, there are plenty of bugs. We use [GitHub issues](https://github.com/superseriousbusiness/gotosocial/issues?q=is%3Aissue+is%3Aopen+label%3Abug) to track these.
|
||||
Since GoToSocial is still in beta, there are plenty of bugs. We use [GitHub issues](https://github.com/superseriousbusiness/gotosocial/issues?q=is%3Aissue+is%3Aopen+label%3Abug) to track these.
|
||||
|
||||
Since every ActivityPub server implementation has a slightly different interpretation of the protocol, some servers don't quite federate properly with GoToSocial yet. We're tracking these issues [in this project](https://github.com/superseriousbusiness/gotosocial/projects/4). Eventually, we want to make sure that any implementation that can federate nicely with Mastodon should also be able to federate with GoToSocial.
|
||||
|
||||
|
|
15
ROADMAP.md
|
@ -1,10 +1,10 @@
|
|||
# Roadmap to Beta <!-- omit in toc -->
|
||||
|
||||
This document contains the roadmap for GoToSocial to be considered eligible for its first [beta release](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta).
|
||||
This document contains the roadmap for GoToSocial to be considered eligible for its first proper [stable release](https://en.wikipedia.org/wiki/Software_release_life_cycle#Stable_release).
|
||||
|
||||
All the info contained in this document is best-guess only. It's useful to have a rough timeline we can direct people to, but things will undoubtedly change along the way; don't hold us to anything in this doc!
|
||||
|
||||
Thank you to [NLnet](https://nlnet.nl) for helping to fund the alpha phase of GoToSocial development and get us moving towards beta!
|
||||
Thank you to [NLnet](https://nlnet.nl) for helping to fund the alpha and beta phases of GoToSocial development!
|
||||
|
||||
Big thank you to all of our [Open Collective](https://opencollective.com/gotosocial) and [Liberapay](https://liberapay.com/gotosocial) contributors, who've helped us keep the lights on! 💕
|
||||
|
||||
|
@ -17,6 +17,7 @@ Big thank you to all of our [Open Collective](https://opencollective.com/gotosoc
|
|||
- [Early 2024](#early-2024)
|
||||
- [BETA milestone](#beta-milestone)
|
||||
- [Remainder 2024 - early 2025](#remainder-2024---early-2025)
|
||||
- [On the way out of BETA to STABLE RELEASE](#on-the-way-out-of-beta-to-stable-release)
|
||||
- [Wishlist](#wishlist)
|
||||
|
||||
## Beta Aims
|
||||
|
@ -61,7 +62,7 @@ What follows is a rough timeline of features that will be implemented on the roa
|
|||
|
||||
### BETA milestone
|
||||
|
||||
Completion of all above features indicates that we are now in the BETA phase of GoToSocial. We foresee this happening around Feb/March 2024.
|
||||
Completion of all above features indicates that we are now in the BETA phase of GoToSocial. We foresee this happening around Feb/March 2024. EDIT: It ended up happening in September/October 2024, whoops!
|
||||
|
||||
### Remainder 2024 - early 2025
|
||||
|
||||
|
@ -69,9 +70,9 @@ These are provided in no specific order.
|
|||
|
||||
- [x] **Filters v2** -- implement v2 of the filters API.
|
||||
- [x] **Mute accounts** -- mute accounts to prevent their posts showing up in your home timeline (optional: for limited period of time).
|
||||
- [ ] **Non-replyable posts** -- design a non-replyable post path for GoToSocial based on https://github.com/mastodon/mastodon/issues/14762#issuecomment-1196889788; allow users to create non-replyable posts.
|
||||
- [x] **Non-replyable posts** -- design a non-replyable post path for GoToSocial based on https://github.com/mastodon/mastodon/issues/14762#issuecomment-1196889788; allow users to create non-replyable posts.
|
||||
- [ ] **Block + allow list subscriptions** -- allow instance admins to subscribe their instance to plaintext domain block/allow lists (much of the work for this is already in place).
|
||||
- [ ] **Direct conversation view** -- allow users to easily page through all direct-message conversations they're a part of.
|
||||
- [x] **Direct conversation view** -- allow users to easily page through all direct-message conversations they're a part of.
|
||||
- [ ] **Oauth token management** -- create / view / invalidate OAuth tokens via the settings panel.
|
||||
- [ ] **Status EDIT support** -- edit statuses that you've created, without having to delete + redraft. Federate edits out properly.
|
||||
- [ ] **Fediverse relay support** -- publish posts to relays, pull posts from relays.
|
||||
|
@ -80,6 +81,10 @@ These are provided in no specific order.
|
|||
|
||||
More tbd!
|
||||
|
||||
### On the way out of BETA to STABLE RELEASE
|
||||
|
||||
Tbd.
|
||||
|
||||
## Wishlist
|
||||
|
||||
These cool things will be implemented if time allows (because we really want them):
|
||||
|
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 90 KiB |
BIN
docs/assets/markdown-post.png
Normal file
After Width: | Height: | Size: 87 KiB |
BIN
docs/assets/theme-blurple-dark.png
Normal file
After Width: | Height: | Size: 650 KiB |
BIN
docs/assets/theme-blurple-light.png
Normal file
After Width: | Height: | Size: 652 KiB |
BIN
docs/assets/theme-brutalist-dark.png
Normal file
After Width: | Height: | Size: 635 KiB |
BIN
docs/assets/theme-brutalist-light.png
Normal file
After Width: | Height: | Size: 639 KiB |
BIN
docs/assets/theme-ecks-pee.png
Normal file
After Width: | Height: | Size: 855 KiB |
BIN
docs/assets/theme-midnight-trip.png
Normal file
After Width: | Height: | Size: 631 KiB |
BIN
docs/assets/theme-rainforest.png
Normal file
After Width: | Height: | Size: 637 KiB |
BIN
docs/assets/theme-soft.png
Normal file
After Width: | Height: | Size: 680 KiB |
BIN
docs/assets/theme-solarized-dark.png
Normal file
After Width: | Height: | Size: 658 KiB |
BIN
docs/assets/theme-solarized-light.png
Normal file
After Width: | Height: | Size: 663 KiB |
BIN
docs/assets/theme-sunset.png
Normal file
After Width: | Height: | Size: 653 KiB |
|
@ -36,6 +36,6 @@ To see posts, you have to start following people! Once you've followed a few peo
|
|||
|
||||
We introduced a sign-up flow in v0.16.0. The server you want to sign up to must have enabled registrations/sign-ups, as detailed [right here](./admin/signups.md).
|
||||
|
||||
## Why's it still in alpha?
|
||||
## Why's it still in Beta?
|
||||
|
||||
Take a look at the [list of open bugs](https://github.com/superseriousbusiness/gotosocial/issues?q=is%3Aissue+is%3Aopen+label%3Abug) and the [roadmap](https://github.com/superseriousbusiness/gotosocial/blob/main/ROADMAP.md) for a more detailed rundown.
|
||||
|
|
|
@ -20,7 +20,7 @@ You can find more detail on system requirements below, but in short you should a
|
|||
|
||||
For a small instance (1-20 active users), GoToSocial will likely hover consistently between 250MB and 350MB of RAM usage once the internal caches are hydrated:
|
||||
|
||||
![Grafana graph showing GoToSocial heap in use hovering around 300MB and spiking occasionally to 400MB-500MB.](../assets/getting-started-memory-graph.png)
|
||||
![Grafana graph showing GoToSocial heap in use hovering around 250MB and spiking occasionally to 400MB-500MB.](../assets/getting-started-memory-graph.png)
|
||||
|
||||
In the graph above you can see that RAM usage spikes during periods of load. This happens, for example, when when a status gets boosted by someone with many followers, or when the embedded `ffmpeg` binary is decoding or reencoding media files into thumbnails (especially larger video files).
|
||||
|
||||
|
|
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/superseriousbusiness/gotosocial
|
||||
|
||||
go 1.22.2
|
||||
go 1.23
|
||||
|
||||
replace modernc.org/sqlite => gitlab.com/NyaaaWhatsUpDoc/sqlite v1.29.9-concurrency-workaround
|
||||
|
||||
|
|
|
@ -145,8 +145,8 @@ func validateCreateEmoji(form *apimodel.EmojiCreateRequest) error {
|
|||
return errors.New("no emoji given")
|
||||
}
|
||||
|
||||
maxSize := config.GetMediaEmojiLocalMaxSize()
|
||||
if form.Image.Size > int64(maxSize) {
|
||||
maxSize := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
if form.Image.Size > maxSize {
|
||||
return fmt.Errorf("emoji image too large: image is %dKB but size limit for custom emojis is %dKB", form.Image.Size/1024, maxSize/1024)
|
||||
}
|
||||
|
||||
|
|
|
@ -208,8 +208,8 @@ func validateUpdateEmoji(form *apimodel.EmojiUpdateRequest) error {
|
|||
}
|
||||
|
||||
if hasImage {
|
||||
maxSize := config.GetMediaEmojiLocalMaxSize()
|
||||
if form.Image.Size > int64(maxSize) {
|
||||
maxSize := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
if form.Image.Size > maxSize {
|
||||
return fmt.Errorf("emoji image too large: image is %dKB but size limit for custom emojis is %dKB", form.Image.Size/1024, maxSize/1024)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ type MediaDimensions struct {
|
|||
Duration float32 `json:"duration,omitempty"`
|
||||
// Bitrate of the media in bits per second.
|
||||
// example: 1000000
|
||||
Bitrate int `json:"bitrate,omitempty"`
|
||||
Bitrate uint64 `json:"bitrate,omitempty"`
|
||||
// Size of the media, in the format `[width]x[height]`.
|
||||
// Not set for audio.
|
||||
// example: 1920x1080
|
||||
|
|
2
internal/cache/domain/domain.go
vendored
|
@ -220,7 +220,7 @@ func (n *node) getChild(part string) *node {
|
|||
|
||||
for i < j {
|
||||
// avoid overflow when computing h
|
||||
h := int(uint(i+j) >> 1)
|
||||
h := int(uint(i+j) >> 1) // #nosec G115
|
||||
// i ≤ h < j
|
||||
|
||||
if n.child[h].part < part {
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
|
@ -407,13 +408,12 @@ func maxOpenConns() int {
|
|||
// deriveBunDBPGOptions takes an application config and returns either a ready-to-use set of options
|
||||
// with sensible defaults, or an error if it's not satisfied by the provided config.
|
||||
func deriveBunDBPGOptions() (*pgx.ConnConfig, error) {
|
||||
url := config.GetDbPostgresConnectionString()
|
||||
|
||||
// if database URL is defined, ignore other DB related configuration fields
|
||||
if url != "" {
|
||||
cfg, err := pgx.ParseConfig(url)
|
||||
return cfg, err
|
||||
// If database URL is defined, ignore
|
||||
// other DB-related configuration fields.
|
||||
if url := config.GetDbPostgresConnectionString(); url != "" {
|
||||
return pgx.ParseConfig(url)
|
||||
}
|
||||
|
||||
// these are all optional, the db adapter figures out defaults
|
||||
address := config.GetDbAddress()
|
||||
|
||||
|
@ -477,7 +477,10 @@ func deriveBunDBPGOptions() (*pgx.ConnConfig, error) {
|
|||
cfg.Host = address
|
||||
}
|
||||
if port := config.GetDbPort(); port > 0 {
|
||||
cfg.Port = uint16(port)
|
||||
if port > math.MaxUint16 {
|
||||
return nil, errors.New("invalid port, must be in range 1-65535")
|
||||
}
|
||||
cfg.Port = uint16(port) // #nosec G115 -- Just validated above.
|
||||
}
|
||||
if u := config.GetDbUser(); u != "" {
|
||||
cfg.User = u
|
||||
|
|
|
@ -71,17 +71,26 @@ func NewSender() (Sender, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
username := config.GetSMTPUsername()
|
||||
password := config.GetSMTPPassword()
|
||||
host := config.GetSMTPHost()
|
||||
port := config.GetSMTPPort()
|
||||
from := config.GetSMTPFrom()
|
||||
msgIDHost := config.GetHost()
|
||||
var (
|
||||
username = config.GetSMTPUsername()
|
||||
password = config.GetSMTPPassword()
|
||||
host = config.GetSMTPHost()
|
||||
port = config.GetSMTPPort()
|
||||
from = config.GetSMTPFrom()
|
||||
msgIDHost = config.GetHost()
|
||||
smtpAuth smtp.Auth
|
||||
)
|
||||
|
||||
if username == "" || password == "" {
|
||||
smtpAuth = nil
|
||||
} else {
|
||||
smtpAuth = smtp.PlainAuth("", username, password, host)
|
||||
}
|
||||
|
||||
return &sender{
|
||||
hostAddress: fmt.Sprintf("%s:%d", host, port),
|
||||
from: from,
|
||||
auth: smtp.PlainAuth("", username, password, host),
|
||||
auth: smtpAuth,
|
||||
msgIDHost: msgIDHost,
|
||||
template: t,
|
||||
}, nil
|
||||
|
|
|
@ -97,11 +97,11 @@ func (d *Dereferencer) GetEmoji(
|
|||
}
|
||||
|
||||
// Get maximum supported remote emoji size.
|
||||
maxsz := config.GetMediaEmojiRemoteMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Prepare data function to dereference remote emoji media.
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return tsport.DereferenceMedia(ctx, url, int64(maxsz))
|
||||
return tsport.DereferenceMedia(ctx, url, maxsz)
|
||||
}
|
||||
|
||||
// Create new emoji with prepared info.
|
||||
|
@ -189,11 +189,11 @@ func (d *Dereferencer) RefreshEmoji(
|
|||
}
|
||||
|
||||
// Get maximum supported remote emoji size.
|
||||
maxsz := config.GetMediaEmojiRemoteMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Prepare data function to dereference remote emoji media.
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return tsport.DereferenceMedia(ctx, url, int64(maxsz))
|
||||
return tsport.DereferenceMedia(ctx, url, maxsz)
|
||||
}
|
||||
|
||||
// Update emoji with prepared info.
|
||||
|
@ -255,11 +255,11 @@ func (d *Dereferencer) RecacheEmoji(
|
|||
}
|
||||
|
||||
// Get maximum supported remote emoji size.
|
||||
maxsz := config.GetMediaEmojiRemoteMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Prepare data function to dereference remote emoji media.
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return tsport.DereferenceMedia(ctx, url, int64(maxsz))
|
||||
return tsport.DereferenceMedia(ctx, url, maxsz)
|
||||
}
|
||||
|
||||
// Recache emoji with prepared info.
|
||||
|
|
|
@ -77,14 +77,14 @@ func (d *Dereferencer) GetMedia(
|
|||
}
|
||||
|
||||
// Get maximum supported remote media size.
|
||||
maxsz := config.GetMediaRemoteMaxSize()
|
||||
maxsz := int64(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Create media with prepared info.
|
||||
return d.mediaManager.CreateMedia(
|
||||
ctx,
|
||||
accountID,
|
||||
func(ctx context.Context) (io.ReadCloser, error) {
|
||||
return tsport.DereferenceMedia(ctx, url, int64(maxsz))
|
||||
return tsport.DereferenceMedia(ctx, url, maxsz)
|
||||
},
|
||||
info,
|
||||
)
|
||||
|
@ -168,14 +168,14 @@ func (d *Dereferencer) RefreshMedia(
|
|||
}
|
||||
|
||||
// Get maximum supported remote media size.
|
||||
maxsz := config.GetMediaRemoteMaxSize()
|
||||
maxsz := int64(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Recache media with prepared info,
|
||||
// this will also update media in db.
|
||||
return d.mediaManager.CacheMedia(
|
||||
attach,
|
||||
func(ctx context.Context) (io.ReadCloser, error) {
|
||||
return tsport.DereferenceMedia(ctx, url, int64(maxsz))
|
||||
return tsport.DereferenceMedia(ctx, url, maxsz)
|
||||
},
|
||||
), nil
|
||||
},
|
||||
|
|
|
@ -340,14 +340,14 @@ func (c *Client) do(r *Request) (rsp *http.Response, retry bool, err error) {
|
|||
|
||||
if u, _ := strconv.ParseUint(after, 10, 32); u != 0 {
|
||||
// An integer no. of backoff seconds was provided.
|
||||
r.backoff = time.Duration(u) * time.Second
|
||||
r.backoff = time.Duration(u) * time.Second // #nosec G115 -- We clamp backoff below.
|
||||
} else if at, _ := http.ParseTime(after); !at.Before(now) {
|
||||
// An HTTP formatted future date-time was provided.
|
||||
r.backoff = at.Sub(now)
|
||||
}
|
||||
|
||||
// Don't let their provided backoff exceed our max.
|
||||
if max := baseBackoff * time.Duration(c.retries); //
|
||||
if max := baseBackoff * time.Duration(c.retries); // #nosec G115 -- We control c.retries.
|
||||
r.backoff > max {
|
||||
r.backoff = max
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
|
@ -224,8 +225,11 @@ func ffprobe(ctx context.Context, filepath string) (*result, error) {
|
|||
// Show specifically stream codec names, types, frame rate, duration, dimens, and pixel format.
|
||||
"stream=codec_name,codec_type,r_frame_rate,duration_ts,width,height,pix_fmt" + ":" +
|
||||
|
||||
// Show orientation.
|
||||
"tags=orientation",
|
||||
// Show orientation tag.
|
||||
"tags=orientation" + ":" +
|
||||
|
||||
// Show rotation data.
|
||||
"side_data=rotation",
|
||||
|
||||
// Limit to reading the first
|
||||
// 1s of data looking for "rotation"
|
||||
|
@ -490,7 +494,7 @@ func (res *ffprobeResult) Process() (*result, error) {
|
|||
}
|
||||
|
||||
// Check extra packet / frame information
|
||||
// for provided orientation (not always set).
|
||||
// for provided orientation (if provided).
|
||||
for _, pf := range res.PacketsAndFrames {
|
||||
|
||||
// Ensure frame contains tags.
|
||||
|
@ -498,23 +502,24 @@ func (res *ffprobeResult) Process() (*result, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
// Ensure orientation not
|
||||
// already been specified.
|
||||
if r.orientation != 0 {
|
||||
return nil, errors.New("multiple sets of orientation data")
|
||||
}
|
||||
|
||||
// Trim any space from orientation value.
|
||||
str := strings.TrimSpace(pf.Tags.Orientation)
|
||||
|
||||
// Parse as integer value.
|
||||
i, _ := strconv.Atoi(str)
|
||||
if i < 0 || i >= 9 {
|
||||
orient, _ := strconv.Atoi(str)
|
||||
if orient < 0 || orient >= 9 {
|
||||
return nil, errors.New("invalid orientation data")
|
||||
}
|
||||
|
||||
// Set orientation.
|
||||
r.orientation = i
|
||||
// Ensure different value has
|
||||
// not already been specified.
|
||||
if r.orientation != 0 &&
|
||||
orient != r.orientation {
|
||||
return nil, errors.New("multiple sets of orientation / rotation data")
|
||||
}
|
||||
|
||||
// Set new orientation.
|
||||
r.orientation = orient
|
||||
}
|
||||
|
||||
// Preallocate streams to max possible lengths.
|
||||
|
@ -544,16 +549,75 @@ func (res *ffprobeResult) Process() (*result, error) {
|
|||
if p := strings.SplitN(str, "/", 2); len(p) == 2 {
|
||||
n, _ := strconv.ParseUint(p[0], 10, 32)
|
||||
d, _ := strconv.ParseUint(p[1], 10, 32)
|
||||
num, den = uint32(n), uint32(d)
|
||||
|
||||
if n > math.MaxUint32 || d > math.MaxUint32 {
|
||||
return nil, gtserror.Newf("overflowed numerator or denominator")
|
||||
}
|
||||
num, den = uint32(n), uint32(d) // #nosec G115 -- Just checked.
|
||||
} else {
|
||||
n, _ := strconv.ParseUint(p[0], 10, 32)
|
||||
num = uint32(n)
|
||||
|
||||
if n > math.MaxUint32 {
|
||||
return nil, gtserror.Newf("overflowed numerator")
|
||||
}
|
||||
num = uint32(n) // #nosec G115 -- Just checked.
|
||||
}
|
||||
|
||||
// Set final divised framerate.
|
||||
framerate = float32(num / den)
|
||||
}
|
||||
|
||||
// Check for embedded sidedata
|
||||
// which may contain rotation data.
|
||||
for _, d := range s.SideDataList {
|
||||
|
||||
// Ensure frame side
|
||||
// data IS rotation data.
|
||||
if d.Rotation == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Drop any decimal
|
||||
// rotation value.
|
||||
rot := int(d.Rotation)
|
||||
|
||||
// Round rotation to multiple of 90.
|
||||
// More granularity is not needed.
|
||||
if q := rot % 90; q > 45 {
|
||||
rot += (90 - q)
|
||||
} else {
|
||||
rot -= q
|
||||
}
|
||||
|
||||
// Drop any value above 360
|
||||
// or below -360, these are
|
||||
// just repeat full turns.
|
||||
//
|
||||
// Then convert to
|
||||
// orientation value.
|
||||
var orient int
|
||||
switch rot % 360 {
|
||||
case 0:
|
||||
orient = orientationNormal
|
||||
case 90, -270:
|
||||
orient = orientationRotate90
|
||||
case 180:
|
||||
orient = orientationRotate180
|
||||
case 270, -90:
|
||||
orient = orientationRotate270
|
||||
}
|
||||
|
||||
// Ensure different value has
|
||||
// not already been specified.
|
||||
if r.orientation != 0 &&
|
||||
orient != r.orientation {
|
||||
return nil, errors.New("multiple sets of orientation / rotation data")
|
||||
}
|
||||
|
||||
// Set new orientation.
|
||||
r.orientation = orient
|
||||
}
|
||||
|
||||
// Append video stream data to result.
|
||||
r.video = append(r.video, videoStream{
|
||||
stream: stream{codec: s.CodecName},
|
||||
|
@ -580,6 +644,7 @@ type ffprobeResult struct {
|
|||
type ffprobePacketOrFrame struct {
|
||||
Type string `json:"type"`
|
||||
Tags ffprobeTags `json:"tags"`
|
||||
// SideDataList []ffprobeSideData `json:"side_data_list"`
|
||||
}
|
||||
|
||||
type ffprobeTags struct {
|
||||
|
@ -587,13 +652,18 @@ type ffprobeTags struct {
|
|||
}
|
||||
|
||||
type ffprobeStream struct {
|
||||
CodecName string `json:"codec_name"`
|
||||
CodecType string `json:"codec_type"`
|
||||
PixFmt string `json:"pix_fmt"`
|
||||
RFrameRate string `json:"r_frame_rate"`
|
||||
DurationTS uint `json:"duration_ts"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
CodecName string `json:"codec_name"`
|
||||
CodecType string `json:"codec_type"`
|
||||
PixFmt string `json:"pix_fmt"`
|
||||
RFrameRate string `json:"r_frame_rate"`
|
||||
DurationTS uint `json:"duration_ts"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
SideDataList []ffprobeSideData `json:"side_data_list"`
|
||||
}
|
||||
|
||||
type ffprobeSideData struct {
|
||||
Rotation float64 `json:"rotation"`
|
||||
}
|
||||
|
||||
type ffprobeFormat struct {
|
||||
|
|
|
@ -399,9 +399,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
g16 := uint16(s[1])
|
||||
b16 := uint16(s[2])
|
||||
a16 := uint16(a)
|
||||
d[0] = uint8(r16 * 0xff / a16)
|
||||
d[1] = uint8(g16 * 0xff / a16)
|
||||
d[2] = uint8(b16 * 0xff / a16)
|
||||
d[0] = uint8(r16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[3] = a
|
||||
}
|
||||
j += 4
|
||||
|
@ -431,9 +431,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
g32 := uint32(s[2])<<8 | uint32(s[3])
|
||||
b32 := uint32(s[4])<<8 | uint32(s[5])
|
||||
a32 := uint32(s[6])<<8 | uint32(s[7])
|
||||
d[0] = uint8((r32 * 0xffff / a32) >> 8)
|
||||
d[1] = uint8((g32 * 0xffff / a32) >> 8)
|
||||
d[2] = uint8((b32 * 0xffff / a32) >> 8)
|
||||
d[0] = uint8((r32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8((g32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8((b32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
}
|
||||
d[3] = a
|
||||
j += 4
|
||||
|
@ -530,9 +530,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
}
|
||||
|
||||
d := dst[j : j+4 : j+4]
|
||||
d[0] = uint8(r)
|
||||
d[1] = uint8(g)
|
||||
d[2] = uint8(b)
|
||||
d[0] = uint8(r) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b) // #nosec G115 -- Overflow desired.
|
||||
d[3] = 0xff
|
||||
|
||||
iy++
|
||||
|
@ -569,9 +569,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
d := dst[j : j+4 : j+4]
|
||||
switch a16 {
|
||||
case 0xffff:
|
||||
d[0] = uint8(r16 >> 8)
|
||||
d[1] = uint8(g16 >> 8)
|
||||
d[2] = uint8(b16 >> 8)
|
||||
d[0] = uint8(r16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[3] = 0xff
|
||||
case 0:
|
||||
d[0] = 0
|
||||
|
@ -579,10 +579,10 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
d[2] = 0
|
||||
d[3] = 0
|
||||
default:
|
||||
d[0] = uint8(((r16 * 0xffff) / a16) >> 8)
|
||||
d[1] = uint8(((g16 * 0xffff) / a16) >> 8)
|
||||
d[2] = uint8(((b16 * 0xffff) / a16) >> 8)
|
||||
d[3] = uint8(a16 >> 8)
|
||||
d[0] = uint8(((r16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(((g16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(((b16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[3] = uint8(a16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
}
|
||||
j += 4
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ func clampFloat(x float64) uint8 {
|
|||
return 255
|
||||
}
|
||||
if v > 0 {
|
||||
return uint8(v)
|
||||
return uint8(v) // #nosec G115 -- Just checked.
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
|
|||
refetchIDs []string
|
||||
)
|
||||
|
||||
// Get max supported remote emoji media size.
|
||||
maxsz := config.GetMediaEmojiRemoteMaxSize()
|
||||
|
||||
// page through emojis 20 at a time, looking for those with missing images
|
||||
for {
|
||||
// Fetch next block of emojis from database
|
||||
|
@ -111,8 +108,10 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
|
|||
continue
|
||||
}
|
||||
|
||||
// Get max supported remote emoji media size.
|
||||
maxsz := int64(config.GetMediaEmojiRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
dataFunc := func(ctx context.Context) (reader io.ReadCloser, err error) {
|
||||
return dereferenceMedia(ctx, emojiImageIRI, int64(maxsz))
|
||||
return dereferenceMedia(ctx, emojiImageIRI, maxsz)
|
||||
}
|
||||
|
||||
processingEmoji, err := m.UpdateEmoji(ctx, emoji, dataFunc, AdditionalEmojiInfo{
|
||||
|
|
|
@ -462,11 +462,11 @@ func (p *Processor) UpdateAvatar(
|
|||
gtserror.WithCode,
|
||||
) {
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if avatar.Size > int64(maxsz) {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if avatar.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ func (p *Processor) UpdateAvatar(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Write to instance storage.
|
||||
return p.c.StoreLocalMedia(ctx,
|
||||
|
@ -507,11 +507,11 @@ func (p *Processor) UpdateHeader(
|
|||
gtserror.WithCode,
|
||||
) {
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if header.Size > int64(maxsz) {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if header.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ func (p *Processor) UpdateHeader(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Write to instance storage.
|
||||
return p.c.StoreLocalMedia(ctx,
|
||||
|
|
|
@ -45,11 +45,11 @@ func (p *Processor) EmojiCreate(
|
|||
) (*apimodel.Emoji, gtserror.WithCode) {
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.Image.Size > int64(maxsz) {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
if form.Image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ func (p *Processor) EmojiCreate(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
@ -441,11 +441,11 @@ func (p *Processor) emojiUpdateModify(
|
|||
// We can do both at the same time :)
|
||||
|
||||
// Get maximum supported local emoji size.
|
||||
maxsz := config.GetMediaEmojiLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if image.Size > int64(maxsz) {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %s", maxsz)
|
||||
if image.Size > maxsz {
|
||||
text := fmt.Sprintf("emoji exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ func (p *Processor) emojiUpdateModify(
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
data := func(context.Context) (io.ReadCloser, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ import (
|
|||
func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, gtserror.WithCode) {
|
||||
|
||||
// Get maximum supported local media size.
|
||||
maxsz := config.GetMediaLocalMaxSize()
|
||||
maxsz := int64(config.GetMediaLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
|
||||
// Ensure media within size bounds.
|
||||
if form.File.Size > int64(maxsz) {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %s", maxsz)
|
||||
if form.File.Size > maxsz {
|
||||
text := fmt.Sprintf("media exceeds configured max size: %d", maxsz)
|
||||
return nil, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
|
|||
}
|
||||
|
||||
// Wrap the multipart file reader to ensure is limited to max.
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, int64(maxsz))
|
||||
rc, _, _ := iotools.UpdateReadCloserLimit(mpfile, maxsz)
|
||||
|
||||
// Create local media and write to instance storage.
|
||||
attachment, errWithCode := p.c.StoreLocalMedia(ctx,
|
||||
|
|
|
@ -647,7 +647,7 @@ func (c *Converter) AttachmentToAPIAttachment(ctx context.Context, media *gtsmod
|
|||
Size: toAPISize(media.FileMeta.Original.Width, media.FileMeta.Original.Height),
|
||||
FrameRate: toAPIFrameRate(media.FileMeta.Original.Framerate),
|
||||
Duration: util.PtrOrZero(media.FileMeta.Original.Duration),
|
||||
Bitrate: int(util.PtrOrZero(media.FileMeta.Original.Bitrate)),
|
||||
Bitrate: util.PtrOrZero(media.FileMeta.Original.Bitrate),
|
||||
}
|
||||
|
||||
// Copy over local file URL.
|
||||
|
@ -1551,9 +1551,9 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
instance.Configuration.Statuses.CharactersReservedPerURL = instanceStatusesCharactersReservedPerURL
|
||||
instance.Configuration.Statuses.SupportedMimeTypes = instanceStatusesSupportedMimeTypes
|
||||
instance.Configuration.MediaAttachments.SupportedMimeTypes = media.SupportedMIMETypes
|
||||
instance.Configuration.MediaAttachments.ImageSizeLimit = int(config.GetMediaRemoteMaxSize())
|
||||
instance.Configuration.MediaAttachments.ImageSizeLimit = int(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.MediaAttachments.ImageMatrixLimit = instanceMediaAttachmentsImageMatrixLimit
|
||||
instance.Configuration.MediaAttachments.VideoSizeLimit = int(config.GetMediaRemoteMaxSize())
|
||||
instance.Configuration.MediaAttachments.VideoSizeLimit = int(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.MediaAttachments.VideoFrameRateLimit = instanceMediaAttachmentsVideoFrameRateLimit
|
||||
instance.Configuration.MediaAttachments.VideoMatrixLimit = instanceMediaAttachmentsVideoMatrixLimit
|
||||
instance.Configuration.Polls.MaxOptions = config.GetStatusesPollMaxOptions()
|
||||
|
@ -1563,7 +1563,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
instance.Configuration.Accounts.AllowCustomCSS = config.GetAccountsAllowCustomCSS()
|
||||
instance.Configuration.Accounts.MaxFeaturedTags = instanceAccountsMaxFeaturedTags
|
||||
instance.Configuration.Accounts.MaxProfileFields = instanceAccountsMaxProfileFields
|
||||
instance.Configuration.Emojis.EmojiSizeLimit = int(config.GetMediaEmojiLocalMaxSize())
|
||||
instance.Configuration.Emojis.EmojiSizeLimit = int(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.OIDCEnabled = config.GetOIDCEnabled()
|
||||
|
||||
// URLs
|
||||
|
@ -1695,9 +1695,9 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
instance.Configuration.Statuses.CharactersReservedPerURL = instanceStatusesCharactersReservedPerURL
|
||||
instance.Configuration.Statuses.SupportedMimeTypes = instanceStatusesSupportedMimeTypes
|
||||
instance.Configuration.MediaAttachments.SupportedMimeTypes = media.SupportedMIMETypes
|
||||
instance.Configuration.MediaAttachments.ImageSizeLimit = int(config.GetMediaRemoteMaxSize())
|
||||
instance.Configuration.MediaAttachments.ImageSizeLimit = int(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.MediaAttachments.ImageMatrixLimit = instanceMediaAttachmentsImageMatrixLimit
|
||||
instance.Configuration.MediaAttachments.VideoSizeLimit = int(config.GetMediaRemoteMaxSize())
|
||||
instance.Configuration.MediaAttachments.VideoSizeLimit = int(config.GetMediaRemoteMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.MediaAttachments.VideoFrameRateLimit = instanceMediaAttachmentsVideoFrameRateLimit
|
||||
instance.Configuration.MediaAttachments.VideoMatrixLimit = instanceMediaAttachmentsVideoMatrixLimit
|
||||
instance.Configuration.Polls.MaxOptions = config.GetStatusesPollMaxOptions()
|
||||
|
@ -1707,7 +1707,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
instance.Configuration.Accounts.AllowCustomCSS = config.GetAccountsAllowCustomCSS()
|
||||
instance.Configuration.Accounts.MaxFeaturedTags = instanceAccountsMaxFeaturedTags
|
||||
instance.Configuration.Accounts.MaxProfileFields = instanceAccountsMaxProfileFields
|
||||
instance.Configuration.Emojis.EmojiSizeLimit = int(config.GetMediaEmojiLocalMaxSize())
|
||||
instance.Configuration.Emojis.EmojiSizeLimit = int(config.GetMediaEmojiLocalMaxSize()) // #nosec G115 -- Already validated.
|
||||
instance.Configuration.OIDCEnabled = config.GetOIDCEnabled()
|
||||
|
||||
// registrations
|
||||
|
|
|
@ -143,7 +143,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
<TextArea
|
||||
field={form.shortDesc}
|
||||
label={`Short description (markdown accepted, max ${shortDescLimit} characters)`}
|
||||
placeholder="A small testing instance for the GoToSocial alpha software."
|
||||
placeholder="A small testing instance for GoToSocial."
|
||||
autoCapitalize="sentences"
|
||||
rows={6}
|
||||
/>
|
||||
|
@ -151,7 +151,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
<TextArea
|
||||
field={form.description}
|
||||
label={`Full description (markdown accepted, max ${descLimit} characters)`}
|
||||
placeholder="A small testing instance for the GoToSocial alpha software. Just trying it out, my main instance is https://example.com"
|
||||
placeholder="A small testing instance for GoToSocial. Just trying it out, my main instance is https://example.com"
|
||||
autoCapitalize="sentences"
|
||||
rows={6}
|
||||
/>
|
||||
|
|