Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdc898c50b | ||
|
|
03656e99a3 | ||
|
|
b0313b8acb | ||
|
|
252a116766 | ||
|
|
5120b071d1 |
@@ -1,4 +1,3 @@
|
|||||||
Dockerfile
|
|
||||||
target
|
target
|
||||||
.mongo
|
.mongo
|
||||||
.env
|
.env
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
# MongoDB URI
|
|
||||||
MONGODB=mongodb://localhost
|
|
||||||
|
|
||||||
# URL to where the Revolt app is publicly accessible
|
|
||||||
REVOLT_APP_URL=http://local.revolt.chat:5000
|
|
||||||
|
|
||||||
# URL to where the API is publicly accessible
|
|
||||||
REVOLT_PUBLIC_URL=http://local.revolt.chat:8000
|
|
||||||
VITE_API_URL=http://local.revolt.chat:8000
|
|
||||||
|
|
||||||
# URL to where the WebSocket server is publicly accessible
|
|
||||||
REVOLT_EXTERNAL_WS_URL=ws://local.revolt.chat:9000
|
|
||||||
|
|
||||||
# URL to where Autumn is publicly available
|
|
||||||
AUTUMN_PUBLIC_URL=http://local.revolt.chat:3000
|
|
||||||
|
|
||||||
# URL to where January is publicly available
|
|
||||||
JANUARY_PUBLIC_URL=http://local.revolt.chat:7000
|
|
||||||
|
|
||||||
# URL to where Vortex is publicly available
|
|
||||||
# VOSO_PUBLIC_URL=https://voso.revolt.chat
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## hCaptcha Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
# If you are sure that you don't want to use hCaptcha, set to 1.
|
|
||||||
REVOLT_UNSAFE_NO_CAPTCHA=1
|
|
||||||
|
|
||||||
# hCaptcha API key
|
|
||||||
# REVOLT_HCAPTCHA_KEY=0x0000000000000000000000000000000000000000
|
|
||||||
|
|
||||||
# hCaptcha site key
|
|
||||||
# REVOLT_HCAPTCHA_SITEKEY=10000000-ffff-ffff-ffff-000000000001
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## Email Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
# If you are sure that you don't want to use email verification, set to 1.
|
|
||||||
REVOLT_UNSAFE_NO_EMAIL=1
|
|
||||||
|
|
||||||
# SMTP host
|
|
||||||
# REVOLT_SMTP_HOST=smtp.example.com
|
|
||||||
|
|
||||||
# SMTP username
|
|
||||||
# REVOLT_SMTP_USERNAME=noreply@example.com
|
|
||||||
|
|
||||||
# SMTP password
|
|
||||||
# REVOLT_SMTP_PASSWORD=CHANGEME
|
|
||||||
|
|
||||||
# SMTP From header
|
|
||||||
# REVOLT_SMTP_FROM=Revolt <noreply@example.com>
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## Application Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
# Whether to only allow users to sign up if they have an invite code
|
|
||||||
REVOLT_INVITE_ONLY=0
|
|
||||||
|
|
||||||
# Maximum number of people that can be in a group chat
|
|
||||||
REVOLT_MAX_GROUP_SIZE=150
|
|
||||||
|
|
||||||
# VAPID keys for push notifications
|
|
||||||
# Generate using this guide: https://gitlab.insrt.uk/revolt/delta/-/wikis/vapid
|
|
||||||
# --> Please replace these keys before going into production! <--
|
|
||||||
REVOLT_VAPID_PRIVATE_KEY=LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUJSUWpyTWxLRnBiVWhsUHpUbERvcEliYk1yeVNrNXpKYzVYVzIxSjJDS3hvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFWnkrQkg2TGJQZ2hEa3pEempXOG0rUXVPM3pCajRXT1phdkR6ZU00c0pqbmFwd1psTFE0WAp1ZDh2TzVodU94QWhMQlU3WWRldVovWHlBdFpWZmNyQi9BPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
|
|
||||||
REVOLT_VAPID_PUBLIC_KEY=BGcvgR-i2z4IQ5Mw841vJvkLjt8wY-FjmWrw83jOLCY52qcGZS0OF7nfLzuYbjsQISwVO2HXrmf18gLWVX3Kwfw=
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## Vortex configuration
|
|
||||||
##
|
|
||||||
|
|
||||||
# VOSO_MANAGE_TOKEN=CHANGEME
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
name: "CLA Assistant"
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created]
|
|
||||||
pull_request_target:
|
|
||||||
types: [opened,closed,synchronize]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
CLAssistant:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: "CLA Assistant"
|
|
||||||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
|
||||||
# Beta Release
|
|
||||||
uses: cla-assistant/github-action@v2.1.3-beta
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# the below token should have repo scope and must be manually added by you in the repository's secret
|
|
||||||
PERSONAL_ACCESS_TOKEN : ${{ secrets.PAT }}
|
|
||||||
with:
|
|
||||||
path-to-signatures: 'signatures/version1/cla.json'
|
|
||||||
path-to-document: 'https://github.com/revoltchat/cla/blob/master/CLA.md' # e.g. a CLA or a DCO document
|
|
||||||
# branch should not be protected
|
|
||||||
branch: 'master'
|
|
||||||
allowlist: insertish,bot*
|
|
||||||
|
|
||||||
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
|
|
||||||
remote-organization-name: revoltchat
|
|
||||||
remote-repository-name: cla
|
|
||||||
create-file-commit-message: 'cla(create): creating file for storing CLA Signatures'
|
|
||||||
signed-commit-message: 'cla(sign): $contributorName has signed the CLA in #$pullRequestNo'
|
|
||||||
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
|
|
||||||
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
|
|
||||||
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
|
|
||||||
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
|
|
||||||
#use-dco-flag: true - If you are using DCO instead of CLA
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
name: Docker Test & Publish
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "master"
|
|
||||||
tags:
|
|
||||||
- "*"
|
|
||||||
paths-ignore:
|
|
||||||
- ".github/**"
|
|
||||||
- "!.github/workflows/docker.yml"
|
|
||||||
- ".vscode/**"
|
|
||||||
- ".gitignore"
|
|
||||||
- "LICENSE"
|
|
||||||
- "README"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "master"
|
|
||||||
paths:
|
|
||||||
- "Dockerfile"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
base:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Build base image (amd64)
|
|
||||||
steps:
|
|
||||||
# Configure build environment
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
# Authenticate with GHCR
|
|
||||||
- name: Login to Github Container Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Build all projects and cache
|
|
||||||
- name: Build Base Image
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ghcr.io/revoltchat/base:latest
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
publish_amd64:
|
|
||||||
needs: [base]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
project: [delta, bonfire]
|
|
||||||
name: Build ${{ matrix.project }} image (amd64)
|
|
||||||
steps:
|
|
||||||
# Configure build environment
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
# Authenticate with Docker Hub and GHCR
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
- name: Login to Github Container Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Resolve the correct project
|
|
||||||
- uses: kanga333/variable-mapper@master
|
|
||||||
id: export
|
|
||||||
with:
|
|
||||||
key: "${{ matrix.project }}"
|
|
||||||
map: |
|
|
||||||
{
|
|
||||||
"delta": {
|
|
||||||
"path": "crates/delta",
|
|
||||||
"tag": "revoltchat/server"
|
|
||||||
},
|
|
||||||
"bonfire": {
|
|
||||||
"path": "crates/bonfire",
|
|
||||||
"tag": "revoltchat/bonfire"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export_to: output
|
|
||||||
|
|
||||||
# Configure metadata
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: ${{ steps.export.outputs.tag }}, ghcr.io/${{ steps.export.outputs.tag }}
|
|
||||||
|
|
||||||
# Build crate image
|
|
||||||
- name: Publish
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64
|
|
||||||
file: ${{ steps.export.outputs.path }}/Dockerfile
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
Rocket.toml
|
Rocket.toml
|
||||||
target
|
target
|
||||||
.data
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/*"]
|
members = ["crates/bonfire", "crates/delta", "crates/quark", "crates/revcord/*"]
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# Build Stage
|
|
||||||
FROM rustlang/rust:nightly-slim AS builder
|
|
||||||
USER 0:0
|
|
||||||
WORKDIR /home/rust/src
|
|
||||||
|
|
||||||
# Install build requirements
|
|
||||||
RUN apt-get update && apt-get install -y libssl-dev pkg-config
|
|
||||||
|
|
||||||
# Build all crates
|
|
||||||
COPY Cargo.toml Cargo.lock ./
|
|
||||||
COPY crates ./crates
|
|
||||||
RUN cargo build --locked --release
|
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
This is a monorepo for the Revolt backend.
|
This is a monorepo for the Revolt backend.
|
||||||
|
|
||||||
| Crate | Path | Description |
|
| Crate | Description |
|
||||||
| ---------------- | ---------------------------------------------- | ------------------------------------ |
|
| ---------------- | ------------------------------------ |
|
||||||
| `delta` | [crates/delta](crates/delta) | REST API server |
|
| `delta` | REST API server |
|
||||||
| `bonfire` | [crates/bonfire](crates/bonfire) | WebSocket events server |
|
| `bonfire` | WebSocket events server |
|
||||||
| `quark` | [crates/quark](crates/quark) | Models and logic |
|
| `quark` | Models and logic |
|
||||||
<!--| `revcord/api` | [crates/revcord/api](crates/revcord/api) | Discord REST translation layer |
|
| `revcord/api` | Discord REST translation layer |
|
||||||
| `revcord/ws` | [crates/revcord/ws](crates/revcord/ws) | Discord gateway translation layer |
|
| `revcord/ws` | Discord gateway translation layer |
|
||||||
| `revcord/models` | [crates/revcord/models](crates/revcord/models) | Discord models and quark translation |-->
|
| `revcord/models` | Discord models and quark translation |
|
||||||
|
|
||||||
Note: `january`, `autumn`, and `vortex` are yet to be moved into this monorepo.
|
Note: `january`, `autumn`, and `vortex` are yet to be moved into this monorepo.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Build base image
|
|
||||||
docker build -t revolt.chat/base:latest -f Dockerfile .
|
|
||||||
|
|
||||||
# Build crates
|
|
||||||
docker build -t revolt.chat/delta:latest -f crates/delta/Dockerfile .
|
|
||||||
docker build -t revolt.chat/bonfire:latest -f crates/bonfire/Dockerfile .
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.5.5"
|
version = "1.0.6-patch.2"
|
||||||
license = "AGPL-3.0-or-later"
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
# Build Stage
|
# Build Stage
|
||||||
FROM ghcr.io/revoltchat/base:latest AS builder
|
FROM rustlang/rust:nightly-slim AS builder
|
||||||
RUN cargo install --locked --path crates/bonfire
|
USER 0:0
|
||||||
|
WORKDIR /home/rust/src
|
||||||
|
|
||||||
|
RUN USER=root cargo new --bin bonfire
|
||||||
|
WORKDIR /home/rust/src/bonfire
|
||||||
|
RUN apt-get update && apt-get install -y libssl-dev pkg-config
|
||||||
|
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY src ./src
|
||||||
|
RUN cargo install --locked --path .
|
||||||
|
|
||||||
# Bundle Stage
|
# Bundle Stage
|
||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
RUN apt-get update && apt-get install -y ca-certificates
|
RUN apt-get update && apt-get install -y ca-certificates
|
||||||
COPY --from=builder /usr/local/cargo/bin/revolt-bonfire ./
|
COPY --from=builder /usr/local/cargo/bin/bonfire ./
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD ["./revolt-bonfire"]
|
CMD ["./bonfire"]
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../LICENSE
|
|
||||||
@@ -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.
|
||||||
|
|
||||||
|
Revolt Bonfire
|
||||||
|
Copyright (C) 2022 Pawel Makles
|
||||||
|
|
||||||
|
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/>.
|
||||||
@@ -14,7 +14,7 @@ mod websocket;
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Configure requirements for Bonfire.
|
// Configure requirements for Bonfire.
|
||||||
revolt_quark::configure!();
|
let _guard = revolt_quark::setup_logging();
|
||||||
database::connect().await;
|
database::connect().await;
|
||||||
|
|
||||||
// Clean up the current region information.
|
// Clean up the current region information.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.5.5"
|
version = "0.5.3-5-patch.2"
|
||||||
license = "AGPL-3.0-or-later"
|
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@@ -18,6 +17,7 @@ linkify = "0.6.0"
|
|||||||
once_cell = "1.4.1"
|
once_cell = "1.4.1"
|
||||||
env_logger = "0.7.1"
|
env_logger = "0.7.1"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
ctrlc = { version = "3.0", features = ["termination"] }
|
||||||
|
|
||||||
# Lang. Utilities
|
# Lang. Utilities
|
||||||
regex = "1"
|
regex = "1"
|
||||||
@@ -43,6 +43,7 @@ async-std = { version = "1.8.0", features = ["tokio1", "tokio02", "attributes"]
|
|||||||
|
|
||||||
# internal util
|
# internal util
|
||||||
lettre = "0.10.0-alpha.4"
|
lettre = "0.10.0-alpha.4"
|
||||||
|
rauth = { git = "https://github.com/insertish/rauth", rev = "001a9698c56cea79e69e4ae71d7bc2cb48aec1a6" }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
redis = { version = "0.21.2", features = ["async-std-comp"] }
|
redis = { version = "0.21.2", features = ["async-std-comp"] }
|
||||||
@@ -50,14 +51,14 @@ mobc = { version = "0.7.3" }
|
|||||||
mobc-redis = { version = "0.7.0", default-features = false, features = ["async-std-comp"] }
|
mobc-redis = { version = "0.7.0", default-features = false, features = ["async-std-comp"] }
|
||||||
|
|
||||||
# web
|
# web
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.1", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
mongodb = { version = "1.2.2", features = ["async-std-runtime"], default-features = false }
|
||||||
rocket_rauth = { git = "https://github.com/insertish/rauth", rev = "9c3f9bb58a549a51546bd748274130ac4a667cb4" }
|
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
||||||
|
|
||||||
# spec generation
|
# spec generation
|
||||||
schemars = "0.8.8"
|
schemars = "0.8.8"
|
||||||
# rocket_okapi = "0.8.0-rc.1"
|
# rocket_okapi = "0.8.0-rc.1"
|
||||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120", features = [ "swagger" ] }
|
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "dcf0df115596ee07a587a7a543cddf3d7944645b", features = [ "swagger" ] }
|
||||||
|
|
||||||
# quark
|
# quark
|
||||||
revolt-quark = { path = "../quark" }
|
revolt-quark = { path = "../quark" }
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
# Build Stage
|
# Build Stage
|
||||||
FROM ghcr.io/revoltchat/base:latest AS builder
|
FROM rustlang/rust:nightly-slim AS builder
|
||||||
RUN cargo install --locked --path crates/delta
|
USER 0:0
|
||||||
|
WORKDIR /home/rust/src
|
||||||
|
|
||||||
|
RUN USER=root cargo new --bin revolt
|
||||||
|
WORKDIR /home/rust/src/revolt
|
||||||
|
RUN apt-get update && apt-get install -y libssl-dev pkg-config
|
||||||
|
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY assets ./assets
|
||||||
|
COPY src ./src
|
||||||
|
RUN cargo install --locked --path .
|
||||||
|
|
||||||
# Bundle Stage
|
# Bundle Stage
|
||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
RUN apt-get update && apt-get install -y ca-certificates
|
RUN apt-get update && apt-get install -y ca-certificates
|
||||||
COPY --from=builder /usr/local/cargo/bin/revolt-delta ./
|
COPY --from=builder /usr/local/cargo/bin/revolt ./
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
ENV ROCKET_ADDRESS 0.0.0.0
|
ENV ROCKET_ADDRESS 0.0.0.0
|
||||||
ENV ROCKET_PORT 8000
|
ENV ROCKET_PORT 8000
|
||||||
CMD ["./revolt-delta"]
|
CMD ["./revolt"]
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../LICENSE
|
|
||||||
@@ -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.
|
||||||
|
|
||||||
|
Revolt Delta
|
||||||
|
Copyright (C) 2022 Pawel Makles
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
@@ -6,46 +6,144 @@ extern crate rocket_okapi;
|
|||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
extern crate ctrlc;
|
||||||
|
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
pub mod version;
|
||||||
|
|
||||||
use revolt_quark::rauth::RAuth;
|
use log::info;
|
||||||
|
use rauth::{
|
||||||
|
config::{Captcha, Config, EmailVerification, SMTPSettings, Template, Templates},
|
||||||
|
logic::Auth,
|
||||||
|
};
|
||||||
|
use revolt_quark::variables::delta::{
|
||||||
|
APP_URL, HCAPTCHA_KEY, INVITE_ONLY, SMTP_FROM, SMTP_HOST, SMTP_PASSWORD, SMTP_USERNAME,
|
||||||
|
USE_EMAIL, USE_HCAPTCHA,
|
||||||
|
};
|
||||||
use revolt_quark::DatabaseInfo;
|
use revolt_quark::DatabaseInfo;
|
||||||
|
use rocket_cors::AllowedOrigins;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[launch]
|
#[async_std::main]
|
||||||
async fn rocket() -> _ {
|
async fn main() {
|
||||||
// Configure logging and environment
|
let _guard = revolt_quark::setup_logging();
|
||||||
revolt_quark::configure!();
|
|
||||||
|
info!(
|
||||||
|
"Starting Revolt server [version {}].",
|
||||||
|
crate::version::VERSION
|
||||||
|
);
|
||||||
|
|
||||||
// Ensure environment variables are present
|
|
||||||
revolt_quark::variables::delta::preflight_checks();
|
revolt_quark::variables::delta::preflight_checks();
|
||||||
|
|
||||||
// Setup database
|
#[cfg(debug_assertions)]
|
||||||
|
ctrlc::set_handler(move || {
|
||||||
|
// Force ungraceful exit to avoid hang.
|
||||||
|
std::process::exit(0);
|
||||||
|
})
|
||||||
|
.expect("Error setting Ctrl-C handler");
|
||||||
|
|
||||||
|
let cors = rocket_cors::CorsOptions {
|
||||||
|
allowed_origins: AllowedOrigins::All,
|
||||||
|
allowed_methods: [
|
||||||
|
"Get", "Put", "Post", "Delete", "Options", "Head", "Trace", "Connect", "Patch",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.map(|s| FromStr::from_str(s).unwrap())
|
||||||
|
.collect(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.to_cors()
|
||||||
|
.expect("Failed to create CORS.");
|
||||||
|
|
||||||
|
let mut config = Config {
|
||||||
|
email_verification: if *USE_EMAIL {
|
||||||
|
EmailVerification::Enabled {
|
||||||
|
smtp: SMTPSettings {
|
||||||
|
from: (*SMTP_FROM).to_string(),
|
||||||
|
host: (*SMTP_HOST).to_string(),
|
||||||
|
username: (*SMTP_USERNAME).to_string(),
|
||||||
|
password: (*SMTP_PASSWORD).to_string(),
|
||||||
|
reply_to: Some("support@revolt.chat".into()),
|
||||||
|
port: None,
|
||||||
|
use_tls: None,
|
||||||
|
},
|
||||||
|
expiry: Default::default(),
|
||||||
|
templates: Templates {
|
||||||
|
verify: Template {
|
||||||
|
title: "Verify your Revolt account.".into(),
|
||||||
|
text: include_str!(crate::asset!("templates/verify.txt")).into(),
|
||||||
|
url: format!("{}/login/verify/", *APP_URL),
|
||||||
|
html: None,
|
||||||
|
},
|
||||||
|
reset: Template {
|
||||||
|
title: "Reset your Revolt password.".into(),
|
||||||
|
text: include_str!(crate::asset!("templates/reset.txt")).into(),
|
||||||
|
url: format!("{}/login/reset/", *APP_URL),
|
||||||
|
html: None,
|
||||||
|
},
|
||||||
|
welcome: None,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EmailVerification::Disabled
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
if *INVITE_ONLY {
|
||||||
|
config.invite_only = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if *USE_HCAPTCHA {
|
||||||
|
config.captcha = Captcha::HCaptcha {
|
||||||
|
secret: HCAPTCHA_KEY.clone(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let db = DatabaseInfo::Auto.connect().await.unwrap();
|
let db = DatabaseInfo::Auto.connect().await.unwrap();
|
||||||
db.migrate_database().await.unwrap();
|
db.migrate_database().await.unwrap();
|
||||||
|
|
||||||
// Setup rAuth
|
// This is entirely temporary code until rauth is migrated to quark.
|
||||||
let rauth = RAuth {
|
// (and / or otherwise gets updated to MongoDB v2 driver)
|
||||||
database: db.clone().into(),
|
let mongo_db = mongodb::Client::with_uri_str(
|
||||||
config: revolt_quark::util::rauth::config(),
|
&std::env::var("MONGODB").unwrap_or_else(|_| "mongodb://localhost".to_string()),
|
||||||
};
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to init db connection.");
|
||||||
|
|
||||||
|
rauth::entities::sync_models(&mongo_db.database("revolt")).await;
|
||||||
|
|
||||||
// Launch background task workers.
|
// Launch background task workers.
|
||||||
async_std::task::spawn(revolt_quark::tasks::start_workers(db.clone()));
|
async_std::task::spawn(revolt_quark::tasks::start_workers(db.clone()));
|
||||||
|
|
||||||
// Configure CORS
|
let auth = Auth::new(mongo_db.database("revolt"), config);
|
||||||
let cors = revolt_quark::web::cors::new();
|
|
||||||
|
|
||||||
// Configure Rocket
|
|
||||||
let rocket = rocket::build();
|
let rocket = rocket::build();
|
||||||
routes::mount(rocket)
|
routes::mount(rocket)
|
||||||
.mount("/", revolt_quark::web::cors::catch_all_options_routes())
|
.mount("/", rocket_cors::catch_all_options_routes())
|
||||||
.mount("/", revolt_quark::web::ratelimiter::routes())
|
.mount("/", util::ratelimiter::routes())
|
||||||
.mount("/swagger/", revolt_quark::web::swagger::routes())
|
.mount(
|
||||||
.manage(rauth)
|
"/swagger/",
|
||||||
|
rocket_okapi::swagger_ui::make_swagger_ui(&rocket_okapi::swagger_ui::SwaggerUIConfig {
|
||||||
|
url: "../openapi.json".to_owned(),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.manage(auth)
|
||||||
.manage(db)
|
.manage(db)
|
||||||
.manage(cors.clone())
|
.manage(cors.clone())
|
||||||
.attach(revolt_quark::web::ratelimiter::RatelimitFairing)
|
.attach(util::ratelimiter::RatelimitFairing)
|
||||||
.attach(cors)
|
.attach(cors)
|
||||||
|
.launch()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolve asset
|
||||||
|
macro_rules! asset {
|
||||||
|
($path:literal) => {
|
||||||
|
concat!(env!("CARGO_MANIFEST_DIR"), "/assets/", $path)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use asset;
|
||||||
|
|||||||
@@ -16,18 +16,19 @@ use validator::Validate;
|
|||||||
pub struct DataEditChannel {
|
pub struct DataEditChannel {
|
||||||
/// Channel name
|
/// Channel name
|
||||||
#[validate(length(min = 1, max = 32))]
|
#[validate(length(min = 1, max = 32))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
/// Channel description
|
/// Channel description
|
||||||
#[validate(length(min = 0, max = 1024))]
|
#[validate(length(min = 0, max = 1024))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
/// Group owner
|
|
||||||
owner: Option<String>,
|
|
||||||
/// Icon
|
/// Icon
|
||||||
///
|
///
|
||||||
/// Provide an Autumn attachment Id.
|
/// Provide an Autumn attachment Id.
|
||||||
#[validate(length(min = 1, max = 128))]
|
#[validate(length(min = 1, max = 128))]
|
||||||
icon: Option<String>,
|
icon: Option<String>,
|
||||||
/// Whether this channel is age-restricted
|
/// Whether this channel is age-restricted
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
nsfw: Option<bool>,
|
nsfw: Option<bool>,
|
||||||
#[validate(length(min = 1))]
|
#[validate(length(min = 1))]
|
||||||
remove: Option<Vec<FieldsChannel>>,
|
remove: Option<Vec<FieldsChannel>>,
|
||||||
@@ -58,48 +59,12 @@ pub async fn req(
|
|||||||
&& data.description.is_none()
|
&& data.description.is_none()
|
||||||
&& data.icon.is_none()
|
&& data.icon.is_none()
|
||||||
&& data.nsfw.is_none()
|
&& data.nsfw.is_none()
|
||||||
&& data.owner.is_none()
|
|
||||||
&& data.remove.is_none()
|
&& data.remove.is_none()
|
||||||
{
|
{
|
||||||
return Ok(Json(channel));
|
return Ok(Json(channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut partial: PartialChannel = Default::default();
|
let mut partial: PartialChannel = Default::default();
|
||||||
|
|
||||||
// Transfer group ownership
|
|
||||||
if let Some(new_owner) = data.owner {
|
|
||||||
if let Channel::Group {
|
|
||||||
owner, recipients, ..
|
|
||||||
} = &mut channel
|
|
||||||
{
|
|
||||||
// Make sure we are the owner of this group
|
|
||||||
if owner != &user.id {
|
|
||||||
return Err(Error::NotOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure user is part of group
|
|
||||||
if !recipients.contains(&new_owner) {
|
|
||||||
return Err(Error::NotInGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer ownership
|
|
||||||
partial.owner = Some(new_owner.to_string());
|
|
||||||
let old_owner = std::mem::replace(owner, new_owner.to_string());
|
|
||||||
|
|
||||||
// Notify clients
|
|
||||||
SystemMessage::ChannelOwnershipChanged {
|
|
||||||
from: old_owner,
|
|
||||||
to: new_owner,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
.into_message(channel.id().to_string())
|
|
||||||
.create(db, &channel, None)
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
match &mut channel {
|
match &mut channel {
|
||||||
Channel::Group {
|
Channel::Group {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
use revolt_quark::{
|
|
||||||
models::{message::PartialMessage, User},
|
|
||||||
perms, Db, EmptyResponse, Permission, Ref, Result,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// # Remove All Reactions from Message
|
|
||||||
///
|
|
||||||
/// Remove your own, someone else's or all of a given reaction.
|
|
||||||
///
|
|
||||||
/// Requires `ManageMessages` permission.
|
|
||||||
#[openapi(tag = "Interactions")]
|
|
||||||
#[delete("/<target>/messages/<msg>/reactions")]
|
|
||||||
pub async fn clear_reactions(db: &Db, user: User, target: Ref, msg: Ref) -> Result<EmptyResponse> {
|
|
||||||
let channel = target.as_channel(db).await?;
|
|
||||||
perms(&user)
|
|
||||||
.channel(&channel)
|
|
||||||
.throw_permission_and_view_channel(db, Permission::ManageMessages)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Fetch relevant message
|
|
||||||
let mut message = msg.as_message_in(db, channel.id()).await?;
|
|
||||||
|
|
||||||
// Clear reactions
|
|
||||||
message
|
|
||||||
.update(
|
|
||||||
db,
|
|
||||||
PartialMessage {
|
|
||||||
reactions: Some(Default::default()),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| EmptyResponse)
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ pub async fn req(
|
|||||||
edit.validate()
|
edit.validate()
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
Message::validate_sum(&edit.content, &edit.embeds)?;
|
|
||||||
|
|
||||||
let mut message = msg.as_message(db).await?;
|
let mut message = msg.as_message(db).await?;
|
||||||
if message.channel != target {
|
if message.channel != target {
|
||||||
return Err(Error::NotFound);
|
return Err(Error::NotFound);
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
use revolt_quark::{models::User, perms, Db, EmptyResponse, Permission, Ref, Result};
|
|
||||||
|
|
||||||
/// # Add Reaction to Message
|
|
||||||
///
|
|
||||||
/// React to a given message.
|
|
||||||
#[openapi(tag = "Interactions")]
|
|
||||||
#[put("/<target>/messages/<msg>/reactions/<emoji>")]
|
|
||||||
pub async fn react_message(
|
|
||||||
db: &Db,
|
|
||||||
user: User,
|
|
||||||
target: Ref,
|
|
||||||
msg: Ref,
|
|
||||||
emoji: Ref,
|
|
||||||
) -> Result<EmptyResponse> {
|
|
||||||
let channel = target.as_channel(db).await?;
|
|
||||||
perms(&user)
|
|
||||||
.channel(&channel)
|
|
||||||
.throw_permission_and_view_channel(db, Permission::React)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Fetch relevant message
|
|
||||||
let message = msg.as_message_in(db, channel.id()).await?;
|
|
||||||
|
|
||||||
// Add the reaction
|
|
||||||
message
|
|
||||||
.add_reaction(db, &user, &emoji.id)
|
|
||||||
.await
|
|
||||||
.map(|_| EmptyResponse)
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,10 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use revolt_quark::{
|
use revolt_quark::{
|
||||||
models::{
|
models::{
|
||||||
message::{Interactions, Masquerade, Reply, SendableEmbed},
|
message::{Masquerade, Reply, SendableEmbed},
|
||||||
Message, User,
|
Message, User,
|
||||||
},
|
},
|
||||||
perms,
|
perms, Db, Error, Permission, Ref, Result,
|
||||||
web::idempotency::IdempotencyKey,
|
|
||||||
Db, Error, Permission, Ref, Result,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@@ -16,12 +14,13 @@ use serde::{Deserialize, Serialize};
|
|||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
|
|
||||||
|
use crate::util::idempotency::IdempotencyKey;
|
||||||
|
|
||||||
#[derive(Validate, Serialize, Deserialize, JsonSchema)]
|
#[derive(Validate, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct DataMessageSend {
|
pub struct DataMessageSend {
|
||||||
/// Unique token to prevent duplicate message sending
|
/// Unique token to prevent duplicate message sending
|
||||||
///
|
///
|
||||||
/// **This is deprecated and replaced by `Idempotency-Key`!**
|
/// **This is deprecated and replaced by `Idempotency-Key`!**
|
||||||
#[validate(length(min = 1, max = 64))]
|
|
||||||
nonce: Option<String>,
|
nonce: Option<String>,
|
||||||
|
|
||||||
/// Message content to send
|
/// Message content to send
|
||||||
@@ -33,15 +32,11 @@ pub struct DataMessageSend {
|
|||||||
/// Messages to reply to
|
/// Messages to reply to
|
||||||
replies: Option<Vec<Reply>>,
|
replies: Option<Vec<Reply>>,
|
||||||
/// Embeds to include in message
|
/// Embeds to include in message
|
||||||
///
|
|
||||||
/// Text embed content contributes to the content length cap
|
|
||||||
#[validate(length(min = 1, max = 10))]
|
#[validate(length(min = 1, max = 10))]
|
||||||
embeds: Option<Vec<SendableEmbed>>,
|
embeds: Option<Vec<SendableEmbed>>,
|
||||||
/// Masquerade to apply to this message
|
/// Masquerade to apply to this message
|
||||||
#[validate]
|
#[validate]
|
||||||
masquerade: Option<Masquerade>,
|
masquerade: Option<Masquerade>,
|
||||||
/// Information about how this message should be interacted with
|
|
||||||
interactions: Option<Interactions>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -65,8 +60,6 @@ pub async fn message_send(
|
|||||||
data.validate()
|
data.validate()
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
Message::validate_sum(&data.content, &data.embeds)?;
|
|
||||||
|
|
||||||
idempotency.consume_nonce(data.nonce).await?;
|
idempotency.consume_nonce(data.nonce).await?;
|
||||||
|
|
||||||
let channel = target.as_channel(db).await?;
|
let channel = target.as_channel(db).await?;
|
||||||
@@ -88,7 +81,6 @@ pub async fn message_send(
|
|||||||
channel: channel.id().to_string(),
|
channel: channel.id().to_string(),
|
||||||
author: user.id.clone(),
|
author: user.id.clone(),
|
||||||
masquerade: data.masquerade,
|
masquerade: data.masquerade,
|
||||||
interactions: data.interactions.unwrap_or_default(),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,22 +95,13 @@ pub async fn message_send(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Verify permissions for masquerade.
|
// 2. Verify permissions for masquerade.
|
||||||
if let Some(masq) = &message.masquerade {
|
if message.masquerade.is_some() {
|
||||||
permissions
|
permissions
|
||||||
.throw_permission(db, Permission::Masquerade)
|
.throw_permission(db, Permission::Masquerade)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if masq.colour.is_some() {
|
|
||||||
permissions
|
|
||||||
.throw_permission(db, Permission::ManageRole)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Ensure interactions information is correct
|
// 3. Verify replies are valid.
|
||||||
message.interactions.validate(db, &mut permissions).await?;
|
|
||||||
|
|
||||||
// 4. Verify replies are valid.
|
|
||||||
let mut replies = HashSet::new();
|
let mut replies = HashSet::new();
|
||||||
if let Some(entries) = data.replies {
|
if let Some(entries) = data.replies {
|
||||||
if entries.len() > 5 {
|
if entries.len() > 5 {
|
||||||
@@ -151,19 +134,7 @@ pub async fn message_send(
|
|||||||
.replace(replies.into_iter().collect::<Vec<String>>());
|
.replace(replies.into_iter().collect::<Vec<String>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Process included embeds.
|
// 4. Add attachments to message.
|
||||||
let mut embeds = vec![];
|
|
||||||
if let Some(sendable_embeds) = data.embeds {
|
|
||||||
for sendable_embed in sendable_embeds {
|
|
||||||
embeds.push(sendable_embed.into_embed(db, message_id.clone()).await?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !embeds.is_empty() {
|
|
||||||
message.embeds.replace(embeds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. Add attachments to message.
|
|
||||||
let mut attachments = vec![];
|
let mut attachments = vec![];
|
||||||
if let Some(ids) = &data.attachments {
|
if let Some(ids) = &data.attachments {
|
||||||
if !ids.is_empty() {
|
if !ids.is_empty() {
|
||||||
@@ -189,10 +160,22 @@ pub async fn message_send(
|
|||||||
message.attachments.replace(attachments);
|
message.attachments.replace(attachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Set content
|
// 5. Process included embeds.
|
||||||
|
let mut embeds = vec![];
|
||||||
|
if let Some(sendable_embeds) = data.embeds {
|
||||||
|
for sendable_embed in sendable_embeds {
|
||||||
|
embeds.push(sendable_embed.into_embed(db, message_id.clone()).await?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !embeds.is_empty() {
|
||||||
|
message.embeds.replace(embeds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Set content
|
||||||
message.content = data.content;
|
message.content = data.content;
|
||||||
|
|
||||||
// 8. Pass-through nonce value for clients
|
// 7. Pass-through nonce value for clients
|
||||||
message.nonce = Some(idempotency.into_key());
|
message.nonce = Some(idempotency.into_key());
|
||||||
|
|
||||||
message.create(db, &channel, Some(&user)).await?;
|
message.create(db, &channel, Some(&user)).await?;
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
use revolt_quark::{models::User, perms, Db, EmptyResponse, Permission, Ref, Result};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// # Query Parameters
|
|
||||||
#[derive(Serialize, Deserialize, JsonSchema, FromForm)]
|
|
||||||
pub struct OptionsUnreact {
|
|
||||||
/// Remove a specific user's reaction
|
|
||||||
user_id: Option<String>,
|
|
||||||
/// Remove all reactions
|
|
||||||
remove_all: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # Remove Reaction(s) to Message
|
|
||||||
///
|
|
||||||
/// Remove your own, someone else's or all of a given reaction.
|
|
||||||
///
|
|
||||||
/// Requires `ManageMessages` if changing others' reactions.
|
|
||||||
#[openapi(tag = "Interactions")]
|
|
||||||
#[delete("/<target>/messages/<msg>/reactions/<emoji>?<options..>")]
|
|
||||||
pub async fn unreact_message(
|
|
||||||
db: &Db,
|
|
||||||
user: User,
|
|
||||||
target: Ref,
|
|
||||||
msg: Ref,
|
|
||||||
emoji: Ref,
|
|
||||||
options: OptionsUnreact,
|
|
||||||
) -> Result<EmptyResponse> {
|
|
||||||
let channel = target.as_channel(db).await?;
|
|
||||||
let mut permissions = perms(&user).channel(&channel);
|
|
||||||
permissions
|
|
||||||
.throw_permission_and_view_channel(db, Permission::React)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Check if we need to escalate permissions
|
|
||||||
let remove_all = options.remove_all.unwrap_or_default();
|
|
||||||
if options.user_id.is_some() || remove_all {
|
|
||||||
permissions
|
|
||||||
.throw_permission(db, Permission::ManageMessages)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch relevant message
|
|
||||||
let message = msg.as_message_in(db, channel.id()).await?;
|
|
||||||
|
|
||||||
// Check if we should wipe all of this reaction
|
|
||||||
if remove_all {
|
|
||||||
return message
|
|
||||||
.clear_reaction(db, &emoji.id)
|
|
||||||
.await
|
|
||||||
.map(|_| EmptyResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the reaction
|
|
||||||
message
|
|
||||||
.remove_reaction(db, options.user_id.as_ref().unwrap_or(&user.id), &emoji.id)
|
|
||||||
.await
|
|
||||||
.map(|_| EmptyResponse)
|
|
||||||
}
|
|
||||||
@@ -11,16 +11,13 @@ mod group_remove_member;
|
|||||||
mod invite_create;
|
mod invite_create;
|
||||||
mod members_fetch;
|
mod members_fetch;
|
||||||
mod message_bulk_delete;
|
mod message_bulk_delete;
|
||||||
mod message_clear_reactions;
|
|
||||||
mod message_delete;
|
mod message_delete;
|
||||||
mod message_edit;
|
mod message_edit;
|
||||||
mod message_fetch;
|
mod message_fetch;
|
||||||
mod message_query;
|
mod message_query;
|
||||||
mod message_query_stale;
|
mod message_query_stale;
|
||||||
mod message_react;
|
|
||||||
mod message_search;
|
mod message_search;
|
||||||
mod message_send;
|
mod message_send;
|
||||||
mod message_unreact;
|
|
||||||
mod permissions_set;
|
mod permissions_set;
|
||||||
mod permissions_set_default;
|
mod permissions_set_default;
|
||||||
mod voice_join;
|
mod voice_join;
|
||||||
@@ -47,8 +44,5 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
voice_join::req,
|
voice_join::req,
|
||||||
permissions_set::req,
|
permissions_set::req,
|
||||||
permissions_set_default::req,
|
permissions_set_default::req,
|
||||||
message_react::react_message,
|
|
||||||
message_unreact::unreact_message,
|
|
||||||
message_clear_reactions::clear_reactions
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
use revolt_quark::models::emoji::EmojiParent;
|
|
||||||
use revolt_quark::models::{Emoji, File, User};
|
|
||||||
use revolt_quark::{perms, Db, Error, Permission, Result};
|
|
||||||
use serde::Deserialize;
|
|
||||||
use validator::Validate;
|
|
||||||
|
|
||||||
use crate::util::regex::RE_EMOJI;
|
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
|
||||||
|
|
||||||
/// # Emoji Data
|
|
||||||
#[derive(Validate, Deserialize, JsonSchema)]
|
|
||||||
pub struct DataCreateEmoji {
|
|
||||||
/// Server name
|
|
||||||
#[validate(length(min = 1, max = 32), regex = "RE_EMOJI")]
|
|
||||||
name: String,
|
|
||||||
/// Parent information
|
|
||||||
parent: EmojiParent,
|
|
||||||
/// Whether the emoji is mature
|
|
||||||
#[serde(default)]
|
|
||||||
nsfw: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # Create New Emoji
|
|
||||||
///
|
|
||||||
/// Create an emoji by its Autumn upload id.
|
|
||||||
#[openapi(tag = "Emojis")]
|
|
||||||
#[put("/emoji/<id>", data = "<data>")]
|
|
||||||
pub async fn create_emoji(
|
|
||||||
db: &Db,
|
|
||||||
user: User,
|
|
||||||
id: String,
|
|
||||||
data: Json<DataCreateEmoji>,
|
|
||||||
) -> Result<Json<Emoji>> {
|
|
||||||
let data = data.into_inner();
|
|
||||||
data.validate()
|
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
|
||||||
|
|
||||||
// Bots cannot manage emojis
|
|
||||||
if user.bot.is_some() {
|
|
||||||
return Err(Error::IsBot);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate we have permission to write into parent
|
|
||||||
match &data.parent {
|
|
||||||
EmojiParent::Server { id } => {
|
|
||||||
let server = db.fetch_server(id).await?;
|
|
||||||
|
|
||||||
// Check for permission
|
|
||||||
perms(&user)
|
|
||||||
.server(&server)
|
|
||||||
.throw_permission(db, Permission::ManageCustomisation)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Check that there are no more than 100 emoji
|
|
||||||
// ! FIXME: hardcoded upper limit
|
|
||||||
let emojis = db.fetch_emoji_by_parent_id(&server.id).await?;
|
|
||||||
if emojis.len() > 99 {
|
|
||||||
return Err(Error::TooManyEmoji);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EmojiParent::Detached => return Err(Error::InvalidOperation),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find the relevant attachment
|
|
||||||
let attachment = File::use_emoji(db, &id, &id).await?;
|
|
||||||
|
|
||||||
// Create the emoji object
|
|
||||||
let emoji = Emoji {
|
|
||||||
id,
|
|
||||||
parent: data.parent,
|
|
||||||
creator_id: user.id,
|
|
||||||
name: data.name,
|
|
||||||
animated: "image/gif" == &attachment.content_type,
|
|
||||||
nsfw: data.nsfw,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Save emoji
|
|
||||||
emoji.create(db).await?;
|
|
||||||
Ok(Json(emoji))
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
use revolt_quark::models::{emoji::EmojiParent, User};
|
|
||||||
use revolt_quark::{perms, Db, EmptyResponse, Error, Permission, Ref, Result};
|
|
||||||
|
|
||||||
/// # Delete Emoji
|
|
||||||
///
|
|
||||||
/// Delete an emoji by its id.
|
|
||||||
#[openapi(tag = "Emojis")]
|
|
||||||
#[delete("/emoji/<id>")]
|
|
||||||
pub async fn delete_emoji(db: &Db, user: User, id: Ref) -> Result<EmptyResponse> {
|
|
||||||
// Bots cannot manage emoji
|
|
||||||
if user.bot.is_some() {
|
|
||||||
return Err(Error::IsBot);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch the emoji
|
|
||||||
let emoji = id.as_emoji(db).await?;
|
|
||||||
|
|
||||||
// If we uploaded the emoji, then we have permission to delete it
|
|
||||||
if emoji.creator_id != user.id {
|
|
||||||
// Otherwise, validate we have permission to delete from parent
|
|
||||||
match &emoji.parent {
|
|
||||||
EmojiParent::Server { id } => {
|
|
||||||
let server = db.fetch_server(id).await?;
|
|
||||||
|
|
||||||
// Check for permission
|
|
||||||
perms(&user)
|
|
||||||
.server(&server)
|
|
||||||
.throw_permission(db, Permission::ManageCustomisation)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
EmojiParent::Detached => return Ok(EmptyResponse),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the emoji
|
|
||||||
emoji.delete(db).await.map(|_| EmptyResponse)
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
use revolt_quark::models::{Emoji, User};
|
|
||||||
use revolt_quark::{Db, Ref, Result};
|
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
|
||||||
|
|
||||||
/// # Fetch Emoji
|
|
||||||
///
|
|
||||||
/// Fetch an emoji by its id.
|
|
||||||
#[openapi(tag = "Emojis")]
|
|
||||||
#[get("/emoji/<id>")]
|
|
||||||
pub async fn fetch_emoji(db: &Db, _user: User, id: Ref) -> Result<Json<Emoji>> {
|
|
||||||
id.as_emoji(db).await.map(Json)
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
use rocket::Route;
|
|
||||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
|
||||||
|
|
||||||
mod emoji_create;
|
|
||||||
mod emoji_delete;
|
|
||||||
mod emoji_fetch;
|
|
||||||
|
|
||||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
|
||||||
openapi_get_routes_spec![
|
|
||||||
emoji_create::create_emoji,
|
|
||||||
emoji_delete::delete_emoji,
|
|
||||||
emoji_fetch::fetch_emoji
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ use rocket_okapi::{okapi::openapi3::OpenApi, settings::OpenApiSettings};
|
|||||||
|
|
||||||
mod bots;
|
mod bots;
|
||||||
mod channels;
|
mod channels;
|
||||||
mod customisation;
|
|
||||||
mod invites;
|
mod invites;
|
||||||
mod onboard;
|
mod onboard;
|
||||||
mod push;
|
mod push;
|
||||||
@@ -26,10 +25,8 @@ pub fn mount(mut rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
"/channels" => channels::routes(),
|
"/channels" => channels::routes(),
|
||||||
"/servers" => servers::routes(),
|
"/servers" => servers::routes(),
|
||||||
"/invites" => invites::routes(),
|
"/invites" => invites::routes(),
|
||||||
"/custom" => customisation::routes(),
|
"/auth/account" => rauth::web::account::routes(),
|
||||||
"/auth/account" => rocket_rauth::routes::account::routes(),
|
"/auth/session" => rauth::web::session::routes(),
|
||||||
"/auth/session" => rocket_rauth::routes::session::routes(),
|
|
||||||
"/auth/mfa" => rocket_rauth::routes::mfa::routes(),
|
|
||||||
"/onboard" => onboard::routes(),
|
"/onboard" => onboard::routes(),
|
||||||
"/push" => push::routes(),
|
"/push" => push::routes(),
|
||||||
"/sync" => sync::routes(),
|
"/sync" => sync::routes(),
|
||||||
@@ -80,7 +77,6 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
"Channel Invites",
|
"Channel Invites",
|
||||||
"Channel Permissions",
|
"Channel Permissions",
|
||||||
"Messaging",
|
"Messaging",
|
||||||
"Interactions",
|
|
||||||
"Groups",
|
"Groups",
|
||||||
"Voice"
|
"Voice"
|
||||||
]
|
]
|
||||||
@@ -99,19 +95,12 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
"Invites"
|
"Invites"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Customisation",
|
|
||||||
"tags": [
|
|
||||||
"Emojis"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Authentication",
|
"name": "Authentication",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Account",
|
"Account",
|
||||||
"Session",
|
"Session",
|
||||||
"Onboarding",
|
"Onboarding"
|
||||||
"MFA"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -128,7 +117,7 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
openapi: OpenApi::default_version(),
|
openapi: OpenApi::default_version(),
|
||||||
info: Info {
|
info: Info {
|
||||||
title: "Revolt API".to_owned(),
|
title: "Revolt API".to_owned(),
|
||||||
description: Some("Open source user-first chat platform.".to_owned()),
|
description: Some("User-first privacy focused chat platform.".to_owned()),
|
||||||
terms_of_service: Some("https://revolt.chat/terms".to_owned()),
|
terms_of_service: Some("https://revolt.chat/terms".to_owned()),
|
||||||
contact: Some(Contact {
|
contact: Some(Contact {
|
||||||
name: Some("Revolt Support".to_owned()),
|
name: Some("Revolt Support".to_owned()),
|
||||||
@@ -141,7 +130,7 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
url: Some("https://github.com/revoltchat/delta/blob/master/LICENSE".to_owned()),
|
url: Some("https://github.com/revoltchat/delta/blob/master/LICENSE".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
version: "0.5.3-rc.1".to_owned(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
servers: vec![
|
servers: vec![
|
||||||
@@ -253,11 +242,6 @@ fn custom_openapi_spec() -> OpenApi {
|
|||||||
description: Some("Create and manage sessions".to_owned()),
|
description: Some("Create and manage sessions".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Tag {
|
|
||||||
name: "MFA".to_owned(),
|
|
||||||
description: Some("Multi-factor Authentication".to_owned()),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
Tag {
|
Tag {
|
||||||
name: "Onboarding".to_owned(),
|
name: "Onboarding".to_owned(),
|
||||||
description: Some(
|
description: Some(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::util::regex::RE_USERNAME;
|
use crate::util::regex::RE_USERNAME;
|
||||||
use revolt_quark::{models::User, rauth::models::Session, Database, EmptyResponse, Error, Result};
|
use revolt_quark::{models::User, Database, EmptyResponse, Error, Result};
|
||||||
|
|
||||||
|
use rauth::entities::Session;
|
||||||
use rocket::{serde::json::Json, State};
|
use rocket::{serde::json::Json, State};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
@@ -32,10 +33,13 @@ pub async fn req(
|
|||||||
data.validate()
|
data.validate()
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
let username = User::validate_username(db, data.username).await?;
|
if db.is_username_taken(&data.username).await? {
|
||||||
|
return Err(Error::UsernameTaken);
|
||||||
|
}
|
||||||
|
|
||||||
let user = User {
|
let user = User {
|
||||||
id: session.user_id,
|
id: session.user_id,
|
||||||
username,
|
username: data.username,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use revolt_quark::{models::User, rauth::models::Session};
|
use rauth::entities::Session;
|
||||||
|
use revolt_quark::models::User;
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use revolt_quark::{
|
use revolt_quark::{EmptyResponse, Error, Result};
|
||||||
rauth::{
|
|
||||||
models::{Session, WebPushSubscription},
|
|
||||||
RAuth,
|
|
||||||
},
|
|
||||||
EmptyResponse, Error, Result,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use rauth::{
|
||||||
|
entities::{Model, Session, WebPushSubscription},
|
||||||
|
logic::Auth,
|
||||||
|
};
|
||||||
use rocket::{serde::json::Json, State};
|
use rocket::{serde::json::Json, State};
|
||||||
|
|
||||||
/// # Push Subscribe
|
/// # Push Subscribe
|
||||||
@@ -16,13 +14,13 @@ use rocket::{serde::json::Json, State};
|
|||||||
#[openapi(tag = "Web Push")]
|
#[openapi(tag = "Web Push")]
|
||||||
#[post("/subscribe", data = "<data>")]
|
#[post("/subscribe", data = "<data>")]
|
||||||
pub async fn req(
|
pub async fn req(
|
||||||
rauth: &State<RAuth>,
|
auth: &State<Auth>,
|
||||||
mut session: Session,
|
mut session: Session,
|
||||||
data: Json<WebPushSubscription>,
|
data: Json<WebPushSubscription>,
|
||||||
) -> Result<EmptyResponse> {
|
) -> Result<EmptyResponse> {
|
||||||
session.subscription = Some(data.into_inner());
|
session.subscription = Some(data.into_inner());
|
||||||
session
|
session
|
||||||
.save(&rauth)
|
.save(&auth.db, None)
|
||||||
.await
|
.await
|
||||||
.map(|_| EmptyResponse)
|
.map(|_| EmptyResponse)
|
||||||
.map_err(|_| Error::DatabaseError {
|
.map_err(|_| Error::DatabaseError {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
use revolt_quark::{
|
use revolt_quark::{EmptyResponse, Error, Result};
|
||||||
rauth::{models::Session, RAuth},
|
|
||||||
EmptyResponse, Error, Result,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use rauth::{
|
||||||
|
entities::{Model, Session},
|
||||||
|
logic::Auth,
|
||||||
|
};
|
||||||
use rocket::State;
|
use rocket::State;
|
||||||
|
|
||||||
/// # Unsubscribe
|
/// # Unsubscribe
|
||||||
@@ -10,10 +11,10 @@ use rocket::State;
|
|||||||
/// Remove the Web Push subscription associated with the current session.
|
/// Remove the Web Push subscription associated with the current session.
|
||||||
#[openapi(tag = "Web Push")]
|
#[openapi(tag = "Web Push")]
|
||||||
#[post("/unsubscribe")]
|
#[post("/unsubscribe")]
|
||||||
pub async fn req(rauth: &State<RAuth>, mut session: Session) -> Result<EmptyResponse> {
|
pub async fn req(auth: &State<Auth>, mut session: Session) -> Result<EmptyResponse> {
|
||||||
session.subscription = None;
|
session.subscription = None;
|
||||||
session
|
session
|
||||||
.save(&rauth)
|
.save(&auth.db, None)
|
||||||
.await
|
.await
|
||||||
.map(|_| EmptyResponse)
|
.map(|_| EmptyResponse)
|
||||||
.map_err(|_| Error::DatabaseError {
|
.map_err(|_| Error::DatabaseError {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ pub struct RevoltConfig {
|
|||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub async fn root() -> Result<Json<RevoltConfig>> {
|
pub async fn root() -> Result<Json<RevoltConfig>> {
|
||||||
Ok(Json(RevoltConfig {
|
Ok(Json(RevoltConfig {
|
||||||
revolt: env!("CARGO_PKG_VERSION").to_string(),
|
revolt: crate::version::VERSION.to_string(),
|
||||||
features: RevoltFeatures {
|
features: RevoltFeatures {
|
||||||
captcha: CaptchaFeature {
|
captcha: CaptchaFeature {
|
||||||
enabled: *USE_HCAPTCHA,
|
enabled: *USE_HCAPTCHA,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use revolt_quark::{
|
use revolt_quark::{
|
||||||
models::{server_member::MemberCompositeKey, ServerBan, User},
|
models::{ServerBan, User},
|
||||||
perms, Db, Error, Permission, Ref, Result,
|
perms, Db, Error, Permission, Ref, Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,8 +47,8 @@ pub async fn req(
|
|||||||
.throw_permission(db, Permission::BanMembers)
|
.throw_permission(db, Permission::BanMembers)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// If member exists, check privileges against them
|
let member = target.as_member(db, &server.id).await?;
|
||||||
if let Ok(member) = target.as_member(db, &server.id).await {
|
|
||||||
if member.get_ranking(permissions.server.get().unwrap())
|
if member.get_ranking(permissions.server.get().unwrap())
|
||||||
<= permissions.get_member_rank().unwrap_or(i64::MIN)
|
<= permissions.get_member_rank().unwrap_or(i64::MIN)
|
||||||
{
|
{
|
||||||
@@ -56,18 +56,4 @@ pub async fn req(
|
|||||||
}
|
}
|
||||||
|
|
||||||
server.ban_member(db, member, data.reason).await.map(Json)
|
server.ban_member(db, member, data.reason).await.map(Json)
|
||||||
} else {
|
|
||||||
let server_id = server.id.to_string();
|
|
||||||
server
|
|
||||||
.ban_user(
|
|
||||||
db,
|
|
||||||
MemberCompositeKey {
|
|
||||||
server: server_id,
|
|
||||||
user: target.id,
|
|
||||||
},
|
|
||||||
data.reason,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(Json)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
use revolt_quark::models::{Emoji, User};
|
|
||||||
use revolt_quark::{perms, Db, Ref, Result};
|
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
|
||||||
|
|
||||||
/// # Fetch Server Emoji
|
|
||||||
///
|
|
||||||
/// Fetch all emoji on a server.
|
|
||||||
#[openapi(tag = "Server Customisation")]
|
|
||||||
#[get("/<target>/emojis")]
|
|
||||||
pub async fn list_emoji(db: &Db, user: User, target: Ref) -> Result<Json<Vec<Emoji>>> {
|
|
||||||
let server = target.as_server(db).await?;
|
|
||||||
perms(&user).server(&server).calc(db).await?;
|
|
||||||
|
|
||||||
// Fetch all emoji from server if we can view it
|
|
||||||
db.fetch_emoji_by_parent_id(&server.id).await.map(Json)
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use revolt_quark::{
|
use revolt_quark::{
|
||||||
models::{
|
models::{
|
||||||
server_member::{FieldsMember, PartialMember},
|
server_member::{FieldsMember, PartialMember},
|
||||||
File, Member, User,
|
File, Member, User,
|
||||||
},
|
},
|
||||||
perms, Db, Error, Permission, Ref, Result, Timestamp,
|
perms, Db, Error, Ref, Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
@@ -22,8 +20,6 @@ pub struct DataMemberEdit {
|
|||||||
avatar: Option<String>,
|
avatar: Option<String>,
|
||||||
/// Array of role ids
|
/// Array of role ids
|
||||||
roles: Option<Vec<String>>,
|
roles: Option<Vec<String>>,
|
||||||
/// Timestamp this member is timed out until
|
|
||||||
timeout: Option<Timestamp>,
|
|
||||||
/// Fields to remove from channel object
|
/// Fields to remove from channel object
|
||||||
#[validate(length(min = 1))]
|
#[validate(length(min = 1))]
|
||||||
remove: Option<Vec<FieldsMember>>,
|
remove: Option<Vec<FieldsMember>>,
|
||||||
@@ -45,110 +41,27 @@ pub async fn req(
|
|||||||
data.validate()
|
data.validate()
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|
||||||
// Fetch server, target member and current permissions
|
let server = server.as_server(db).await?;
|
||||||
let mut server = server.as_server(db).await?;
|
perms(&user).server(&server).calc(db).await?;
|
||||||
|
|
||||||
let mut member = target.as_member(db, &server.id).await?;
|
let mut member = target.as_member(db, &server.id).await?;
|
||||||
let mut permissions = perms(&user).server(&server);
|
|
||||||
|
|
||||||
// Check permissions in server
|
|
||||||
let mut required = vec![];
|
|
||||||
|
|
||||||
if data.nickname.is_some()
|
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&FieldsMember::Nickname))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
if user.id == member.id.user {
|
|
||||||
required.push(Permission::ChangeNickname);
|
|
||||||
} else {
|
|
||||||
required.push(Permission::ManageNicknames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if data.avatar.is_some()
|
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&FieldsMember::Avatar))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
if user.id == member.id.user {
|
|
||||||
required.push(Permission::ChangeAvatar);
|
|
||||||
} else {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if data.roles.is_some()
|
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&FieldsMember::Roles))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
required.push(Permission::AssignRoles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if data.timeout.is_some()
|
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&FieldsMember::Timeout))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
required.push(Permission::TimeoutMembers);
|
|
||||||
}
|
|
||||||
|
|
||||||
for permission in required {
|
|
||||||
permissions.throw_permission(db, permission).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve our ranking
|
|
||||||
let our_ranking = permissions.get_member_rank().unwrap_or(i64::MIN);
|
|
||||||
|
|
||||||
// Check that we have permissions to act against this member
|
|
||||||
if member.id.user != user.id
|
|
||||||
&& member.get_ranking(permissions.server.get().unwrap()) <= our_ranking
|
|
||||||
{
|
|
||||||
return Err(Error::NotElevated);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check permissions against roles in diff
|
|
||||||
if let Some(roles) = &data.roles {
|
|
||||||
let current_roles = member.roles.iter().collect::<HashSet<&String>>();
|
|
||||||
|
|
||||||
let new_roles = roles.iter().collect::<HashSet<&String>>();
|
|
||||||
let added_roles: Vec<&&String> = new_roles.difference(¤t_roles).collect();
|
|
||||||
|
|
||||||
for role_id in added_roles {
|
|
||||||
if let Some(role) = server.roles.remove(*role_id) {
|
|
||||||
if role.rank <= our_ranking {
|
|
||||||
return Err(Error::NotElevated);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Err(Error::InvalidRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply edits to the member object
|
|
||||||
let DataMemberEdit {
|
let DataMemberEdit {
|
||||||
nickname,
|
nickname,
|
||||||
avatar,
|
avatar,
|
||||||
roles,
|
roles,
|
||||||
timeout,
|
|
||||||
remove,
|
remove,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
let mut partial = PartialMember {
|
let mut partial = PartialMember {
|
||||||
nickname,
|
nickname,
|
||||||
roles,
|
roles,
|
||||||
timeout,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ! FIXME: calculate permission against member
|
||||||
|
// ! FIXME: also check roles exist lol
|
||||||
|
|
||||||
// 1. Remove fields from object
|
// 1. Remove fields from object
|
||||||
if let Some(fields) = &remove {
|
if let Some(fields) = &remove {
|
||||||
if fields.contains(&FieldsMember::Avatar) {
|
if fields.contains(&FieldsMember::Avatar) {
|
||||||
|
|||||||
@@ -1,27 +1,31 @@
|
|||||||
use rocket::Route;
|
use rocket::Route;
|
||||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||||
|
|
||||||
mod ban_create;
|
|
||||||
mod ban_list;
|
|
||||||
mod ban_remove;
|
|
||||||
mod channel_create;
|
|
||||||
mod emoji_list;
|
|
||||||
mod invites_fetch;
|
|
||||||
mod member_edit;
|
|
||||||
mod member_fetch;
|
|
||||||
mod member_fetch_all;
|
|
||||||
mod member_remove;
|
|
||||||
mod permissions_set;
|
|
||||||
mod permissions_set_default;
|
|
||||||
mod roles_create;
|
|
||||||
mod roles_delete;
|
|
||||||
mod roles_edit;
|
|
||||||
mod server_ack;
|
mod server_ack;
|
||||||
mod server_create;
|
mod server_create;
|
||||||
mod server_delete;
|
mod server_delete;
|
||||||
mod server_edit;
|
mod server_edit;
|
||||||
mod server_fetch;
|
mod server_fetch;
|
||||||
|
|
||||||
|
mod channel_create;
|
||||||
|
|
||||||
|
mod member_edit;
|
||||||
|
mod member_fetch;
|
||||||
|
mod member_fetch_all;
|
||||||
|
mod member_remove;
|
||||||
|
|
||||||
|
mod ban_create;
|
||||||
|
mod ban_list;
|
||||||
|
mod ban_remove;
|
||||||
|
|
||||||
|
mod invites_fetch;
|
||||||
|
|
||||||
|
mod permissions_set;
|
||||||
|
mod permissions_set_default;
|
||||||
|
mod roles_create;
|
||||||
|
mod roles_delete;
|
||||||
|
mod roles_edit;
|
||||||
|
|
||||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||||
openapi_get_routes_spec![
|
openapi_get_routes_spec![
|
||||||
server_create::req,
|
server_create::req,
|
||||||
@@ -42,7 +46,6 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
roles_edit::req,
|
roles_edit::req,
|
||||||
roles_delete::req,
|
roles_delete::req,
|
||||||
permissions_set::req,
|
permissions_set::req,
|
||||||
permissions_set_default::req,
|
permissions_set_default::req
|
||||||
emoji_list::list_emoji
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ use revolt_quark::{
|
|||||||
server::{FieldsRole, PartialRole, Role},
|
server::{FieldsRole, PartialRole, Role},
|
||||||
User,
|
User,
|
||||||
},
|
},
|
||||||
perms,
|
perms, Db, Error, Permission, Ref, Result,
|
||||||
util::regex::RE_COLOUR,
|
|
||||||
Db, Error, Permission, Ref, Result,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
@@ -19,7 +17,7 @@ pub struct DataEditRole {
|
|||||||
#[validate(length(min = 1, max = 32))]
|
#[validate(length(min = 1, max = 32))]
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
/// Role colour
|
/// Role colour
|
||||||
#[validate(length(min = 1, max = 128), regex = "RE_COLOUR")]
|
#[validate(length(min = 1, max = 32))]
|
||||||
colour: Option<String>,
|
colour: Option<String>,
|
||||||
/// Whether this role should be displayed separately
|
/// Whether this role should be displayed separately
|
||||||
hoist: Option<bool>,
|
hoist: Option<bool>,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use revolt_quark::{
|
use revolt_quark::{
|
||||||
models::{
|
models::{
|
||||||
server::{Category, FieldsServer, PartialServer, SystemMessageChannels},
|
server::{Category, FieldsServer, PartialServer, SystemMessageChannels},
|
||||||
@@ -35,8 +33,6 @@ pub struct DataEditServer {
|
|||||||
|
|
||||||
// Whether this server is age-restricted
|
// Whether this server is age-restricted
|
||||||
// nsfw: Option<bool>,
|
// nsfw: Option<bool>,
|
||||||
/// Whether this server is public and should show up on [Revolt Discover](https://rvlt.gg)
|
|
||||||
discoverable: Option<bool>,
|
|
||||||
/// Whether analytics should be collected for this server
|
/// Whether analytics should be collected for this server
|
||||||
///
|
///
|
||||||
/// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
|
/// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
|
||||||
@@ -106,7 +102,6 @@ pub async fn req(
|
|||||||
categories,
|
categories,
|
||||||
system_messages,
|
system_messages,
|
||||||
// nsfw,
|
// nsfw,
|
||||||
discoverable,
|
|
||||||
analytics,
|
analytics,
|
||||||
remove,
|
remove,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -117,7 +112,6 @@ pub async fn req(
|
|||||||
categories,
|
categories,
|
||||||
system_messages,
|
system_messages,
|
||||||
// nsfw,
|
// nsfw,
|
||||||
discoverable,
|
|
||||||
analytics,
|
analytics,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -137,43 +131,29 @@ pub async fn req(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Validate changes
|
// 2. Apply new icon
|
||||||
let mut unknown_channels = HashSet::new();
|
|
||||||
if let Some(system_messages) = &partial.system_messages {
|
|
||||||
unknown_channels = system_messages.clone().into_channel_ids();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(categories) = &partial.categories {
|
|
||||||
let mut channel_ids = HashSet::new();
|
|
||||||
for category in categories {
|
|
||||||
for channel in &category.channels {
|
|
||||||
if channel_ids.contains(channel) {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
channel_ids.insert(channel.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unknown_channels.extend(channel_ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
if !db.check_channels_exist(&unknown_channels).await? {
|
|
||||||
return Err(Error::NotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Apply new icon
|
|
||||||
if let Some(icon) = icon {
|
if let Some(icon) = icon {
|
||||||
partial.icon = Some(File::use_server_icon(db, &icon, &server.id).await?);
|
partial.icon = Some(File::use_server_icon(db, &icon, &server.id).await?);
|
||||||
server.icon = partial.icon.clone();
|
server.icon = partial.icon.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Apply new banner
|
// 3. Apply new banner
|
||||||
if let Some(banner) = banner {
|
if let Some(banner) = banner {
|
||||||
partial.banner = Some(File::use_banner(db, &banner, &server.id).await?);
|
partial.banner = Some(File::use_banner(db, &banner, &server.id).await?);
|
||||||
server.banner = partial.banner.clone();
|
server.banner = partial.banner.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4. Validate changes
|
||||||
|
if let Some(system_messages) = &partial.system_messages {
|
||||||
|
let channels = system_messages.clone().into_channel_ids();
|
||||||
|
if !db
|
||||||
|
.check_channels_exist(&channels.into_iter().collect())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(Error::NotFound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server
|
server
|
||||||
.update(db, partial, remove.unwrap_or_default())
|
.update(db, partial, remove.unwrap_or_default())
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use revolt_quark::models::User;
|
use revolt_quark::models::User;
|
||||||
use revolt_quark::r#impl::UserSettingsImpl;
|
use revolt_quark::r#impl::generic::users::user_settings::UserSettingsImpl;
|
||||||
use revolt_quark::{Db, EmptyResponse, Result};
|
use revolt_quark::{Db, EmptyResponse, Result};
|
||||||
|
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
use revolt_quark::models::User;
|
use revolt_quark::models::User;
|
||||||
use revolt_quark::{Database, Error, Ref, Result};
|
use revolt_quark::{Database, Error, Result};
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
use rocket::State;
|
use rocket::State;
|
||||||
|
|
||||||
/// # Accept Friend Request
|
/// # Send Friend Request / Accept Request
|
||||||
///
|
///
|
||||||
/// Accept another user's friend request.
|
/// Send a friend request to another user or accept another user's friend request.
|
||||||
#[openapi(tag = "Relationships")]
|
#[openapi(tag = "Relationships")]
|
||||||
#[put("/<target>/friend")]
|
#[put("/<username>/friend")]
|
||||||
pub async fn req(db: &State<Database>, user: User, target: Ref) -> Result<Json<User>> {
|
pub async fn req(db: &State<Database>, user: User, username: String) -> Result<Json<User>> {
|
||||||
let mut target = target.as_user(db).await?;
|
let mut target = db.fetch_user_by_username(&username).await?;
|
||||||
|
|
||||||
if user.bot.is_some() || target.bot.is_some() {
|
if user.bot.is_some() || target.bot.is_some() {
|
||||||
return Err(Error::IsBot);
|
return Err(Error::IsBot);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use crate::util::regex::RE_USERNAME;
|
use crate::util::regex::RE_USERNAME;
|
||||||
use revolt_quark::{models::User, rauth::models::Account, Database, Error, Result};
|
use rauth::entities::Account;
|
||||||
|
use revolt_quark::{models::User, Database, Error, Result};
|
||||||
use rocket::{serde::json::Json, State};
|
use rocket::{serde::json::Json, State};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
|
|||||||
@@ -59,6 +59,18 @@ impl rocket_okapi::response::OpenApiResponderInner for CachedFile {
|
|||||||
pub async fn req(target: String) -> CachedFile {
|
pub async fn req(target: String) -> CachedFile {
|
||||||
CachedFile((
|
CachedFile((
|
||||||
ContentType::PNG,
|
ContentType::PNG,
|
||||||
revolt_quark::util::pfp::avatar(target.chars().last().unwrap()),
|
match target.chars().last().unwrap() {
|
||||||
|
// 0123456789ABCDEFGHJKMNPQRSTVWXYZ
|
||||||
|
'0' | '1' | '2' | '3' | 'S' | 'Z' => {
|
||||||
|
include_bytes!(crate::asset!("user/2.png")).to_vec()
|
||||||
|
}
|
||||||
|
'4' | '5' | '6' | '7' | 'T' => include_bytes!(crate::asset!("user/3.png")).to_vec(),
|
||||||
|
'8' | '9' | 'A' | 'B' => include_bytes!(crate::asset!("user/4.png")).to_vec(),
|
||||||
|
'C' | 'D' | 'E' | 'F' | 'V' => include_bytes!(crate::asset!("user/5.png")).to_vec(),
|
||||||
|
'G' | 'H' | 'J' | 'K' | 'W' => include_bytes!(crate::asset!("user/6.png")).to_vec(),
|
||||||
|
'M' | 'N' | 'P' | 'Q' | 'X' => include_bytes!(crate::asset!("user/7.png")).to_vec(),
|
||||||
|
/*'0' | '1' | '2' | '3' | 'R' | 'Y'*/
|
||||||
|
_ => include_bytes!(crate::asset!("user/1.png")).to_vec(),
|
||||||
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ mod find_mutual;
|
|||||||
mod get_default_avatar;
|
mod get_default_avatar;
|
||||||
mod open_dm;
|
mod open_dm;
|
||||||
mod remove_friend;
|
mod remove_friend;
|
||||||
mod send_friend_request;
|
|
||||||
mod unblock_user;
|
mod unblock_user;
|
||||||
|
|
||||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||||
@@ -34,6 +33,5 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
remove_friend::req,
|
remove_friend::req,
|
||||||
block_user::req,
|
block_user::req,
|
||||||
unblock_user::req,
|
unblock_user::req,
|
||||||
send_friend_request::req,
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
use revolt_quark::models::User;
|
|
||||||
use revolt_quark::{Database, Error, Result};
|
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
|
||||||
use rocket::State;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// # User Lookup Information
|
|
||||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub struct DataSendFriendRequest {
|
|
||||||
username: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # Send Friend Request
|
|
||||||
///
|
|
||||||
/// Send a friend request to another user.
|
|
||||||
#[openapi(tag = "Relationships")]
|
|
||||||
#[post("/friend", data = "<data>")]
|
|
||||||
pub async fn req(
|
|
||||||
db: &State<Database>,
|
|
||||||
user: User,
|
|
||||||
data: Json<DataSendFriendRequest>,
|
|
||||||
) -> Result<Json<User>> {
|
|
||||||
let mut target = db.fetch_user_by_username(&data.username).await?;
|
|
||||||
|
|
||||||
if user.bot.is_some() || target.bot.is_some() {
|
|
||||||
return Err(Error::IsBot);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.add_friend(db, &mut target).await?;
|
|
||||||
Ok(Json(target.with_auto_perspective(db, &user).await))
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{Error, Result};
|
|
||||||
|
|
||||||
use async_std::sync::Mutex;
|
use async_std::sync::Mutex;
|
||||||
|
use mongodb::bson::doc;
|
||||||
|
use revolt_quark::{Error, Result};
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rocket::request::{FromRequest, Outcome};
|
use rocket::request::{FromRequest, Outcome};
|
||||||
use rocket_okapi::gen::OpenApiGenerator;
|
use rocket_okapi::gen::OpenApiGenerator;
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
pub mod idempotency;
|
||||||
|
pub mod ratelimiter;
|
||||||
pub mod regex;
|
pub mod regex;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use std::hash::Hasher;
|
|||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use crate::rauth::models::Session;
|
|
||||||
use rocket::fairing::{Fairing, Info, Kind};
|
use rocket::fairing::{Fairing, Info, Kind};
|
||||||
use rocket::http::uri::Origin;
|
use rocket::http::uri::Origin;
|
||||||
use rocket::http::{Method, Status};
|
use rocket::http::{Method, Status};
|
||||||
@@ -23,6 +22,8 @@ use serde::Serialize;
|
|||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
|
||||||
|
use log::info;
|
||||||
|
|
||||||
/// Ratelimit Bucket
|
/// Ratelimit Bucket
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
struct Entry {
|
struct Entry {
|
||||||
@@ -100,13 +101,7 @@ fn resolve_bucket<'r>(request: &'r rocket::Request<'_>) -> (&'r str, Option<&'r
|
|||||||
if let Some(segment) = request.routed_segment(0) {
|
if let Some(segment) = request.routed_segment(0) {
|
||||||
let resource = request.routed_segment(1);
|
let resource = request.routed_segment(1);
|
||||||
match (segment, resource) {
|
match (segment, resource) {
|
||||||
("users", _) => {
|
("users", _) => ("users", None),
|
||||||
if let Some("default_avatar") = request.routed_segment(2) {
|
|
||||||
return ("default_avatar", None);
|
|
||||||
}
|
|
||||||
|
|
||||||
("users", None)
|
|
||||||
}
|
|
||||||
("bots", _) => ("bots", None),
|
("bots", _) => ("bots", None),
|
||||||
("channels", Some(id)) => {
|
("channels", Some(id)) => {
|
||||||
if request.method() == Method::Post {
|
if request.method() == Method::Post {
|
||||||
@@ -143,7 +138,6 @@ fn resolve_bucket_limit(bucket: &str) -> u8 {
|
|||||||
"servers" => 5,
|
"servers" => 5,
|
||||||
"auth" => 15,
|
"auth" => 15,
|
||||||
"auth_delete" => 255,
|
"auth_delete" => 255,
|
||||||
"default_avatar" => 255,
|
|
||||||
"swagger" => 100,
|
"swagger" => 100,
|
||||||
_ => 20,
|
_ => 20,
|
||||||
}
|
}
|
||||||
@@ -213,9 +207,10 @@ impl<'r> FromRequest<'r> for Ratelimiter {
|
|||||||
let ratelimiter = request
|
let ratelimiter = request
|
||||||
.local_cache_async(async {
|
.local_cache_async(async {
|
||||||
use rocket::outcome::Outcome;
|
use rocket::outcome::Outcome;
|
||||||
let identifier = if let Outcome::Success(session) = request.guard::<Session>().await
|
let identifier = if let Outcome::Success(session) =
|
||||||
|
request.guard::<rauth::entities::Session>().await
|
||||||
{
|
{
|
||||||
session.id
|
session.id.expect("`id` on User")
|
||||||
} else {
|
} else {
|
||||||
to_real_ip(request)
|
to_real_ip(request)
|
||||||
};
|
};
|
||||||
@@ -309,11 +304,11 @@ impl<'r> FromRequest<'r> for RatelimitInformation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::get("/ratelimit")]
|
#[get("/ratelimit")]
|
||||||
fn ratelimit_info(info: RatelimitInformation) -> Json<RatelimitInformation> {
|
fn ratelimit_info(info: RatelimitInformation) -> Json<RatelimitInformation> {
|
||||||
Json(info)
|
Json(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<rocket::Route> {
|
pub fn routes() -> Vec<rocket::Route> {
|
||||||
rocket::routes![ratelimit_info]
|
routes![ratelimit_info]
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,4 @@ use regex::Regex;
|
|||||||
/// Block zero width space
|
/// Block zero width space
|
||||||
/// Block lookalike characters
|
/// Block lookalike characters
|
||||||
pub static RE_USERNAME: Lazy<Regex> =
|
pub static RE_USERNAME: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^[^\u200BА-Яа-яΑ-Ωα-ω@#:\n\r\[\]]+$").unwrap());
|
Lazy::new(|| Regex::new(r"^[^\u200BА-Яа-яΑ-Ωα-ω]+$").unwrap());
|
||||||
|
|
||||||
/// Regex for valid emoji names
|
|
||||||
///
|
|
||||||
/// Alphanumeric and underscores
|
|
||||||
pub static RE_EMOJI: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[a-z0-9_]+$").unwrap());
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
pub const VERSION: &str = "0.5.3-5-patch.2";
|
||||||
@@ -1,27 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-quark"
|
name = "revolt-quark"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
license = "AGPL-3.0-or-later"
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
mongo = [ "mongodb" ]
|
mongo = [ "mongodb" ]
|
||||||
rocket_impl = [
|
rocket_impl = [ "rocket" ]
|
||||||
"rocket",
|
test = [ "async-std", "mongo", "mongodb/async-std-runtime", "rocket_impl", "rauth" ]
|
||||||
"rocket_empty",
|
|
||||||
"rocket_cors",
|
|
||||||
|
|
||||||
"lru",
|
|
||||||
"dashmap",
|
|
||||||
|
|
||||||
"rauth/database-mongodb",
|
|
||||||
"rauth/rocket_impl",
|
|
||||||
"rauth/okapi_impl"
|
|
||||||
]
|
|
||||||
|
|
||||||
test = [ "async-std", "mongo", "mongodb/async-std-runtime", "rocket_impl" ]
|
|
||||||
default = [ "test" ]
|
default = [ "test" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -38,8 +25,8 @@ bson = { version = "2.1.0", features = ["chrono-0_4"] }
|
|||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = "0.8.8"
|
schemars = "0.8.8"
|
||||||
okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120" }
|
okapi = { git = "https://github.com/insertish/okapi", rev = "dcf0df115596ee07a587a7a543cddf3d7944645b" }
|
||||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120" }
|
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "dcf0df115596ee07a587a7a543cddf3d7944645b" }
|
||||||
# okapi = "0.7.0-rc.1"
|
# okapi = "0.7.0-rc.1"
|
||||||
# rocket_okapi = "0.8.0-rc.1"
|
# rocket_okapi = "0.8.0-rc.1"
|
||||||
|
|
||||||
@@ -64,29 +51,20 @@ regex = "1.5.5"
|
|||||||
nanoid = "0.4.0"
|
nanoid = "0.4.0"
|
||||||
linkify = "0.8.1"
|
linkify = "0.8.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
indexmap = "1.9.1"
|
|
||||||
impl_ops = "0.1.1"
|
impl_ops = "0.1.1"
|
||||||
num_enum = "0.5.6"
|
num_enum = "0.5.6"
|
||||||
reqwest = "0.11.10"
|
reqwest = "0.11.10"
|
||||||
bitfield = "0.13.2"
|
bitfield = "0.13.2"
|
||||||
once_cell = "1.13.0"
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
lru = { version = "0.7.6", optional = true }
|
|
||||||
dashmap = { version = "5.2.0", optional = true }
|
|
||||||
|
|
||||||
# Web Push
|
# Web Push
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
web-push = "0.7.2"
|
web-push = "0.7.2"
|
||||||
|
|
||||||
# Implementations
|
# Implementations
|
||||||
rocket_http = { optional = true, version = "0.5.0-rc.2" }
|
rauth = { optional = true, git = "https://github.com/insertish/rauth", rev = "001a9698c56cea79e69e4ae71d7bc2cb48aec1a6" }
|
||||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { optional = true, version = "=0.5.0-rc.1", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { optional = true, git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
rocket_http = { optional = true, version = "=0.5.0-rc.1" }
|
||||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
|
||||||
|
|
||||||
# rAuth
|
|
||||||
rauth = { git = "https://github.com/insertish/rauth", rev = "9c3f9bb58a549a51546bd748274130ac4a667cb4", features = [ "async-std-runtime" ] }
|
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = "0.25.0"
|
sentry = "0.25.0"
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../LICENSE
|
|
||||||
@@ -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.
|
||||||
|
|
||||||
|
Revolt Quark
|
||||||
|
Copyright (C) 2022 Pawel Makles
|
||||||
|
|
||||||
|
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/>.
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
You requested to have your account deleted, if you did not perform this action please take measures to secure your account immediately.
|
|
||||||
|
|
||||||
Confirm here: {{url}}
|
|
||||||
|
|
||||||
Sent by Revolt.
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use crate::r#impl::{DummyDb, MongoDb};
|
use crate::r#impl::dummy::DummyDb;
|
||||||
|
use crate::r#impl::mongo::MongoDb;
|
||||||
use crate::AbstractDatabase;
|
use crate::AbstractDatabase;
|
||||||
|
|
||||||
/// Database information to use to create a client
|
/// Database information to use to create a client
|
||||||
@@ -60,14 +61,3 @@ impl Deref for Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Database> for rauth::Database {
|
|
||||||
fn from(val: Database) -> Self {
|
|
||||||
match val {
|
|
||||||
Database::Dummy(_) => rauth::Database::default(),
|
|
||||||
Database::MongoDb(MongoDb(client)) => {
|
|
||||||
rauth::Database::MongoDb(rauth::database::MongoDb(client.database("revolt")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::models::message::{AppendMessage, PartialMessage};
|
|||||||
use crate::models::server::{FieldsRole, FieldsServer, PartialRole, PartialServer};
|
use crate::models::server::{FieldsRole, FieldsServer, PartialRole, PartialServer};
|
||||||
use crate::models::server_member::{FieldsMember, MemberCompositeKey, PartialMember};
|
use crate::models::server_member::{FieldsMember, MemberCompositeKey, PartialMember};
|
||||||
use crate::models::user::{FieldsUser, PartialUser, RelationshipStatus};
|
use crate::models::user::{FieldsUser, PartialUser, RelationshipStatus};
|
||||||
use crate::models::{Channel, Emoji, Member, Message, Server, User, UserSettings};
|
use crate::models::{Channel, Member, Message, Server, User, UserSettings};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
/// WebSocket Client Errors
|
/// WebSocket Client Errors
|
||||||
@@ -52,7 +52,6 @@ pub enum EventV1 {
|
|||||||
servers: Vec<Server>,
|
servers: Vec<Server>,
|
||||||
channels: Vec<Channel>,
|
channels: Vec<Channel>,
|
||||||
members: Vec<Member>,
|
members: Vec<Member>,
|
||||||
emojis: Option<Vec<Emoji>>,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Ping response
|
/// Ping response
|
||||||
@@ -78,29 +77,6 @@ pub enum EventV1 {
|
|||||||
/// Delete message
|
/// Delete message
|
||||||
MessageDelete { id: String, channel: String },
|
MessageDelete { id: String, channel: String },
|
||||||
|
|
||||||
/// New reaction to a message
|
|
||||||
MessageReact {
|
|
||||||
id: String,
|
|
||||||
channel_id: String,
|
|
||||||
user_id: String,
|
|
||||||
emoji_id: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Remove user's reaction from message
|
|
||||||
MessageUnreact {
|
|
||||||
id: String,
|
|
||||||
channel_id: String,
|
|
||||||
user_id: String,
|
|
||||||
emoji_id: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Remove a reaction from message
|
|
||||||
MessageRemoveReaction {
|
|
||||||
id: String,
|
|
||||||
channel_id: String,
|
|
||||||
emoji_id: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Bulk delete messages
|
/// Bulk delete messages
|
||||||
BulkMessageDelete { channel: String, ids: Vec<String> },
|
BulkMessageDelete { channel: String, ids: Vec<String> },
|
||||||
|
|
||||||
@@ -194,10 +170,4 @@ pub enum EventV1 {
|
|||||||
|
|
||||||
/// Settings updated remotely
|
/// Settings updated remotely
|
||||||
UserSettingsUpdate { id: String, update: UserSettings },
|
UserSettingsUpdate { id: String, update: UserSettings },
|
||||||
|
|
||||||
/// New emoji
|
|
||||||
EmojiCreate(Emoji),
|
|
||||||
|
|
||||||
/// Delete emoji
|
|
||||||
EmojiDelete { id: String },
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ impl State {
|
|||||||
|
|
||||||
// Fetch all memberships with their corresponding servers.
|
// Fetch all memberships with their corresponding servers.
|
||||||
let members: Vec<Member> = db.fetch_all_memberships(&user.id).await?;
|
let members: Vec<Member> = db.fetch_all_memberships(&user.id).await?;
|
||||||
|
|
||||||
let server_ids: Vec<String> = members.iter().map(|x| x.id.server.clone()).collect();
|
let server_ids: Vec<String> = members.iter().map(|x| x.id.server.clone()).collect();
|
||||||
let servers = db.fetch_servers(&server_ids).await?;
|
let servers = db.fetch_servers(&server_ids).await?;
|
||||||
|
|
||||||
@@ -152,17 +151,6 @@ impl State {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Fetch customisations.
|
|
||||||
let emojis = Some(
|
|
||||||
db.fetch_emoji_by_parent_ids(
|
|
||||||
&servers
|
|
||||||
.iter()
|
|
||||||
.map(|x| x.id.to_string())
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
)
|
|
||||||
.await?,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Copy data into local state cache.
|
// Copy data into local state cache.
|
||||||
self.cache.users = users.iter().cloned().map(|x| (x.id.clone(), x)).collect();
|
self.cache.users = users.iter().cloned().map(|x| (x.id.clone(), x)).collect();
|
||||||
self.cache
|
self.cache
|
||||||
@@ -214,7 +202,6 @@ impl State {
|
|||||||
servers,
|
servers,
|
||||||
channels,
|
channels,
|
||||||
members,
|
members,
|
||||||
emojis,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,23 +472,27 @@ impl State {
|
|||||||
|
|
||||||
if data.rank.is_some() || data.permissions.is_some() {
|
if data.rank.is_some() || data.permissions.is_some() {
|
||||||
if let Some(member) = self.cache.members.get(id) {
|
if let Some(member) = self.cache.members.get(id) {
|
||||||
if member.roles.contains(role_id) {
|
if let Some(roles) = &member.roles {
|
||||||
|
if roles.contains(role_id) {
|
||||||
queue_server = Some(id.clone());
|
queue_server = Some(id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
EventV1::ServerRoleDelete { id, role_id } => {
|
EventV1::ServerRoleDelete { id, role_id } => {
|
||||||
if let Some(server) = self.cache.servers.get_mut(id) {
|
if let Some(server) = self.cache.servers.get_mut(id) {
|
||||||
server.roles.remove(role_id);
|
server.roles.remove(role_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(member) = self.cache.members.get(id) {
|
if let Some(member) = self.cache.members.get(id) {
|
||||||
if member.roles.contains(role_id) {
|
if let Some(roles) = &member.roles {
|
||||||
|
if roles.contains(role_id) {
|
||||||
queue_server = Some(id.clone());
|
queue_server = Some(id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EventV1::UserRelationship { id, user, .. } => {
|
EventV1::UserRelationship { id, user, .. } => {
|
||||||
self.cache.users.insert(id.clone(), user.clone());
|
self.cache.users.insert(id.clone(), user.clone());
|
||||||
|
|||||||
@@ -39,9 +39,4 @@ impl AbstractAttachment for DummyDb {
|
|||||||
info!("Marked {id} as deleted");
|
info!("Marked {id} as deleted");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()> {
|
|
||||||
info!("Marked {ids:?} as deleted");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -64,22 +64,4 @@ impl AbstractMessage for DummyDb {
|
|||||||
) -> Result<Vec<Message>> {
|
) -> Result<Vec<Message>> {
|
||||||
Ok(vec![self.fetch_message(channel).await.unwrap()])
|
Ok(vec![self.fetch_message(channel).await.unwrap()])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new reaction to a message
|
|
||||||
async fn add_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()> {
|
|
||||||
info!("Add to {id} with {emoji} and {user}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a reaction from a message
|
|
||||||
async fn remove_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()> {
|
|
||||||
info!("Remove {emoji} from {id} for {user}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove reaction from a message
|
|
||||||
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
|
||||||
info!("Clear {emoji} on {id}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
use crate::models::emoji::EmojiParent;
|
|
||||||
use crate::models::Emoji;
|
|
||||||
use crate::{AbstractEmoji, Result};
|
|
||||||
|
|
||||||
use super::super::DummyDb;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl AbstractEmoji for DummyDb {
|
|
||||||
/// Fetch an emoji by its id
|
|
||||||
async fn fetch_emoji(&self, id: &str) -> Result<Emoji> {
|
|
||||||
Ok(Emoji {
|
|
||||||
id: id.into(),
|
|
||||||
name: id.into(),
|
|
||||||
parent: EmojiParent::Server { id: id.into() },
|
|
||||||
creator_id: id.into(),
|
|
||||||
animated: false,
|
|
||||||
nsfw: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch emoji by their ids
|
|
||||||
async fn fetch_emoji_by_parent_id(&self, parent_id: &str) -> Result<Vec<Emoji>> {
|
|
||||||
Ok(vec![self.fetch_emoji(parent_id).await?])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch emoji by their parent ids
|
|
||||||
async fn fetch_emoji_by_parent_ids(&self, _parent_ids: &[String]) -> Result<Vec<Emoji>> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert emoji into database.
|
|
||||||
async fn insert_emoji(&self, emoji: &Emoji) -> Result<()> {
|
|
||||||
info!("Insert {emoji:?}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
|
||||||
info!("Detach {emoji:?}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,8 @@ pub mod admin {
|
|||||||
pub mod migrations;
|
pub mod migrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod media {
|
pub mod autumn {
|
||||||
pub mod attachment;
|
pub mod attachment;
|
||||||
pub mod emoji;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod channels {
|
pub mod channels {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ use crate::{AbstractServerMember, Result};
|
|||||||
|
|
||||||
use super::super::DummyDb;
|
use super::super::DummyDb;
|
||||||
|
|
||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl AbstractServerMember for DummyDb {
|
impl AbstractServerMember for DummyDb {
|
||||||
async fn fetch_member(&self, server: &str, user: &str) -> Result<Member> {
|
async fn fetch_member(&self, server: &str, user: &str) -> Result<Member> {
|
||||||
@@ -13,11 +11,9 @@ impl AbstractServerMember for DummyDb {
|
|||||||
server: server.into(),
|
server: server.into(),
|
||||||
user: user.into(),
|
user: user.into(),
|
||||||
},
|
},
|
||||||
joined_at: Timestamp::now_utc(),
|
|
||||||
nickname: None,
|
nickname: None,
|
||||||
avatar: None,
|
avatar: None,
|
||||||
roles: vec![],
|
roles: None,
|
||||||
timeout: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,4 @@ impl File {
|
|||||||
db.find_and_use_attachment(id, "banners", "server", parent)
|
db.find_and_use_attachment(id, "banners", "server", parent)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn use_emoji(db: &Database, id: &str, parent: &str) -> Result<File> {
|
|
||||||
db.find_and_use_attachment(id, "emojis", "object", parent)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -242,12 +242,7 @@ impl Channel {
|
|||||||
/// Add user to a group
|
/// Add user to a group
|
||||||
pub async fn add_user_to_group(&mut self, db: &Database, user: &str, by: &str) -> Result<()> {
|
pub async fn add_user_to_group(&mut self, db: &Database, user: &str, by: &str) -> Result<()> {
|
||||||
if let Channel::Group { recipients, .. } = self {
|
if let Channel::Group { recipients, .. } = self {
|
||||||
let user = user.to_string();
|
recipients.push(user.to_string());
|
||||||
if recipients.contains(&user) {
|
|
||||||
return Err(Error::AlreadyInGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
recipients.push(user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match &self {
|
match &self {
|
||||||
@@ -305,15 +300,6 @@ impl Channel {
|
|||||||
vec![],
|
vec![],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
SystemMessage::ChannelOwnershipChanged {
|
|
||||||
from: owner.to_string(),
|
|
||||||
to: new_owner.into(),
|
|
||||||
}
|
|
||||||
.into_message(id.to_string())
|
|
||||||
.create(db, self, None)
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
} else {
|
} else {
|
||||||
db.delete_channel(self).await?;
|
db.delete_channel(self).await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -2,25 +2,22 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
use validator::Validate;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1,
|
events::client::EventV1,
|
||||||
models::{
|
models::{
|
||||||
message::{
|
message::{
|
||||||
AppendMessage, BulkMessageResponse, Interactions, PartialMessage, SendableEmbed,
|
AppendMessage, BulkMessageResponse, PartialMessage, SendableEmbed, SystemMessage,
|
||||||
SystemMessage,
|
|
||||||
},
|
},
|
||||||
Channel, Emoji, Message, User,
|
Channel, Message, User,
|
||||||
},
|
},
|
||||||
permissions::PermissionCalculator,
|
|
||||||
presence::presence_filter_online,
|
presence::presence_filter_online,
|
||||||
tasks::ack::AckEvent,
|
tasks::ack::AckEvent,
|
||||||
types::{
|
types::{
|
||||||
january::{Embed, Text},
|
january::{Embed, Text},
|
||||||
push::PushNotification,
|
push::PushNotification,
|
||||||
},
|
},
|
||||||
Database, Error, Permission, Result,
|
Database, Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
@@ -137,17 +134,7 @@ impl Message {
|
|||||||
|
|
||||||
/// Delete a message
|
/// Delete a message
|
||||||
pub async fn delete(self, db: &Database) -> Result<()> {
|
pub async fn delete(self, db: &Database) -> Result<()> {
|
||||||
let file_ids: Vec<String> = self
|
|
||||||
.attachments
|
|
||||||
.map(|files| files.iter().map(|file| file.id.to_string()).collect())
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
if !file_ids.is_empty() {
|
|
||||||
db.mark_attachments_as_deleted(&file_ids).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.delete_message(&self.id).await?;
|
db.delete_message(&self.id).await?;
|
||||||
|
|
||||||
EventV1::MessageDelete {
|
EventV1::MessageDelete {
|
||||||
id: self.id,
|
id: self.id,
|
||||||
channel: self.channel.clone(),
|
channel: self.channel.clone(),
|
||||||
@@ -168,109 +155,6 @@ impl Message {
|
|||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate the sum of content of a message is under threshold
|
|
||||||
pub fn validate_sum(
|
|
||||||
content: &Option<String>,
|
|
||||||
embeds: &Option<Vec<SendableEmbed>>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut running_total = 0;
|
|
||||||
if let Some(content) = content {
|
|
||||||
running_total += content.len();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(embeds) = embeds {
|
|
||||||
for embed in embeds {
|
|
||||||
if let Some(desc) = &embed.description {
|
|
||||||
running_total += desc.len();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if running_total <= 2000 {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(Error::PayloadTooLarge)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add a reaction to a message
|
|
||||||
pub async fn add_reaction(&self, db: &Database, user: &User, emoji: &str) -> Result<()> {
|
|
||||||
// Check how many reactions are already on the message
|
|
||||||
if self.reactions.len() >= 20 {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the emoji is whitelisted
|
|
||||||
if !self.interactions.can_use(emoji) {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the emoji is usable by us
|
|
||||||
if !Emoji::can_use(db, emoji).await? {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send reaction event
|
|
||||||
EventV1::MessageReact {
|
|
||||||
id: self.id.to_string(),
|
|
||||||
channel_id: self.channel.to_string(),
|
|
||||||
user_id: user.id.to_string(),
|
|
||||||
emoji_id: emoji.to_string(),
|
|
||||||
}
|
|
||||||
.p(self.channel.to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Add emoji
|
|
||||||
db.add_reaction(&self.id, emoji, &user.id).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a reaction from a message
|
|
||||||
pub async fn remove_reaction(&self, db: &Database, user: &str, emoji: &str) -> Result<()> {
|
|
||||||
// Check if it actually exists
|
|
||||||
let empty = if let Some(users) = self.reactions.get(emoji) {
|
|
||||||
if !users.contains(user) {
|
|
||||||
return Err(Error::NotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
users.len() == 1
|
|
||||||
} else {
|
|
||||||
return Err(Error::NotFound);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send reaction event
|
|
||||||
EventV1::MessageUnreact {
|
|
||||||
id: self.id.to_string(),
|
|
||||||
channel_id: self.channel.to_string(),
|
|
||||||
user_id: user.to_string(),
|
|
||||||
emoji_id: emoji.to_string(),
|
|
||||||
}
|
|
||||||
.p(self.channel.to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if empty {
|
|
||||||
// If empty, remove the reaction entirely
|
|
||||||
db.clear_reaction(&self.id, emoji).await
|
|
||||||
} else {
|
|
||||||
// Otherwise only remove that one reaction
|
|
||||||
db.remove_reaction(&self.id, emoji, user).await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a reaction from a message
|
|
||||||
pub async fn clear_reaction(&self, db: &Database, emoji: &str) -> Result<()> {
|
|
||||||
// Send reaction event
|
|
||||||
EventV1::MessageRemoveReaction {
|
|
||||||
id: self.id.to_string(),
|
|
||||||
channel_id: self.channel.to_string(),
|
|
||||||
emoji_id: emoji.to_string(),
|
|
||||||
}
|
|
||||||
.p(self.channel.to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Write to database
|
|
||||||
db.clear_reaction(&self.id, emoji).await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait IntoUsers {
|
pub trait IntoUsers {
|
||||||
@@ -342,18 +226,12 @@ impl From<SystemMessage> for String {
|
|||||||
"Channel description changed.".to_string()
|
"Channel description changed.".to_string()
|
||||||
}
|
}
|
||||||
SystemMessage::ChannelIconChanged { .. } => "Channel icon changed.".to_string(),
|
SystemMessage::ChannelIconChanged { .. } => "Channel icon changed.".to_string(),
|
||||||
SystemMessage::ChannelOwnershipChanged { .. } => {
|
|
||||||
"Channel ownership changed.".to_string()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SendableEmbed {
|
impl SendableEmbed {
|
||||||
pub async fn into_embed(self, db: &Database, message_id: String) -> Result<Embed> {
|
pub async fn into_embed(self, db: &Database, message_id: String) -> Result<Embed> {
|
||||||
self.validate()
|
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
|
||||||
|
|
||||||
let media = if let Some(id) = self.media {
|
let media = if let Some(id) = self.media {
|
||||||
Some(
|
Some(
|
||||||
db.find_and_use_attachment(&id, "attachments", "message", &message_id)
|
db.find_and_use_attachment(&id, "attachments", "message", &message_id)
|
||||||
@@ -404,46 +282,3 @@ impl BulkMessageResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Interactions {
|
|
||||||
/// Validate interactions info is correct
|
|
||||||
pub async fn validate(
|
|
||||||
&self,
|
|
||||||
db: &Database,
|
|
||||||
permissions: &mut PermissionCalculator<'_>,
|
|
||||||
) -> Result<()> {
|
|
||||||
if let Some(reactions) = &self.reactions {
|
|
||||||
permissions.throw_permission(db, Permission::React).await?;
|
|
||||||
|
|
||||||
if reactions.len() > 20 {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
for reaction in reactions {
|
|
||||||
if !Emoji::can_use(db, reaction).await? {
|
|
||||||
return Err(Error::InvalidOperation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if we can use a given emoji to react
|
|
||||||
pub fn can_use(&self, emoji: &str) -> bool {
|
|
||||||
if self.restrict_reactions {
|
|
||||||
if let Some(reactions) = &self.reactions {
|
|
||||||
reactions.contains(emoji)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if default initialisation of fields
|
|
||||||
pub fn is_default(&self) -> bool {
|
|
||||||
!self.restrict_reactions && self.reactions.is_none()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
use std::{collections::HashSet, str::FromStr};
|
|
||||||
|
|
||||||
use ulid::Ulid;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
events::client::EventV1,
|
|
||||||
models::{emoji::EmojiParent, Emoji},
|
|
||||||
Database, Result,
|
|
||||||
};
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
/// Permissible emojis
|
|
||||||
static ref PERMISSIBLE_EMOJIS: HashSet<String> = include_str!(crate::asset!("emojis.txt"))
|
|
||||||
.split('\n')
|
|
||||||
.map(|x| x.into())
|
|
||||||
.collect();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Emoji {
|
|
||||||
/// Get parent id
|
|
||||||
fn parent(&self) -> &str {
|
|
||||||
match &self.parent {
|
|
||||||
EmojiParent::Server { id } => id,
|
|
||||||
EmojiParent::Detached => "",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create an emoji
|
|
||||||
pub async fn create(&self, db: &Database) -> Result<()> {
|
|
||||||
db.insert_emoji(self).await?;
|
|
||||||
EventV1::EmojiCreate(self.clone())
|
|
||||||
.p(self.parent().to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Delete an emoji
|
|
||||||
pub async fn delete(self, db: &Database) -> Result<()> {
|
|
||||||
EventV1::EmojiDelete {
|
|
||||||
id: self.id.to_string(),
|
|
||||||
}
|
|
||||||
.p(self.parent().to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
db.detach_emoji(&self).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check whether we can use a given emoji
|
|
||||||
pub async fn can_use(db: &Database, emoji: &str) -> Result<bool> {
|
|
||||||
if Ulid::from_str(emoji).is_ok() {
|
|
||||||
db.fetch_emoji(emoji).await?;
|
|
||||||
Ok(true)
|
|
||||||
} else {
|
|
||||||
Ok(PERMISSIBLE_EMOJIS.contains(emoji))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,8 @@ pub mod admin {
|
|||||||
pub mod migrations;
|
pub mod migrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod media {
|
pub mod autumn {
|
||||||
pub mod attachment;
|
pub mod attachment;
|
||||||
pub mod emoji;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod channels {
|
pub mod channels {
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -191,11 +188,7 @@ impl Server {
|
|||||||
server: self.id.clone(),
|
server: self.id.clone(),
|
||||||
user: user.id.clone(),
|
user: user.id.clone(),
|
||||||
},
|
},
|
||||||
joined_at: Timestamp::now_utc(),
|
..Default::default()
|
||||||
nickname: None,
|
|
||||||
avatar: None,
|
|
||||||
roles: vec![],
|
|
||||||
timeout: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.insert_member(&member).await?;
|
db.insert_member(&member).await?;
|
||||||
@@ -285,18 +278,6 @@ impl Server {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create ban
|
|
||||||
pub async fn ban_user(
|
|
||||||
self,
|
|
||||||
db: &Database,
|
|
||||||
id: MemberCompositeKey,
|
|
||||||
reason: Option<String>,
|
|
||||||
) -> Result<ServerBan> {
|
|
||||||
let ban = ServerBan { id, reason };
|
|
||||||
db.insert_ban(&ban).await?;
|
|
||||||
Ok(ban)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ban a member from a server
|
/// Ban a member from a server
|
||||||
pub async fn ban_member(
|
pub async fn ban_member(
|
||||||
self,
|
self,
|
||||||
@@ -304,31 +285,37 @@ impl Server {
|
|||||||
member: Member,
|
member: Member,
|
||||||
reason: Option<String>,
|
reason: Option<String>,
|
||||||
) -> Result<ServerBan> {
|
) -> Result<ServerBan> {
|
||||||
self.remove_member(db, member.clone(), RemovalIntention::Ban)
|
let ban = ServerBan {
|
||||||
|
id: member.id.clone(),
|
||||||
|
reason,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.remove_member(db, member, RemovalIntention::Ban)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.ban_user(db, member.id, reason).await
|
db.insert_ban(&ban).await?;
|
||||||
|
Ok(ban)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemMessageChannels {
|
impl SystemMessageChannels {
|
||||||
pub fn into_channel_ids(self) -> HashSet<String> {
|
pub fn into_channel_ids(self) -> Vec<String> {
|
||||||
let mut ids = HashSet::new();
|
let mut ids = vec![];
|
||||||
|
|
||||||
if let Some(id) = self.user_joined {
|
if let Some(id) = self.user_joined {
|
||||||
ids.insert(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = self.user_left {
|
if let Some(id) = self.user_left {
|
||||||
ids.insert(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = self.user_kicked {
|
if let Some(id) = self.user_kicked {
|
||||||
ids.insert(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = self.user_banned {
|
if let Some(id) = self.user_banned {
|
||||||
ids.insert(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ids
|
ids
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1,
|
events::client::EventV1,
|
||||||
models::{
|
models::{
|
||||||
@@ -38,8 +36,9 @@ impl Member {
|
|||||||
|
|
||||||
/// Get this user's current ranking
|
/// Get this user's current ranking
|
||||||
pub fn get_ranking(&self, server: &Server) -> i64 {
|
pub fn get_ranking(&self, server: &Server) -> i64 {
|
||||||
|
if let Some(roles) = &self.roles {
|
||||||
let mut value = i64::MAX;
|
let mut value = i64::MAX;
|
||||||
for role in &self.roles {
|
for role in roles {
|
||||||
if let Some(role) = server.roles.get(role) {
|
if let Some(role) = server.roles.get(role) {
|
||||||
if role.rank < value {
|
if role.rank < value {
|
||||||
value = role.rank;
|
value = role.rank;
|
||||||
@@ -48,14 +47,8 @@ impl Member {
|
|||||||
}
|
}
|
||||||
|
|
||||||
value
|
value
|
||||||
}
|
|
||||||
|
|
||||||
/// Check whether this member is in timeout
|
|
||||||
pub fn in_timeout(&self) -> bool {
|
|
||||||
if let Some(timeout) = self.timeout {
|
|
||||||
*timeout > *Timestamp::now_utc()
|
|
||||||
} else {
|
} else {
|
||||||
false
|
i64::MAX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +56,7 @@ impl Member {
|
|||||||
match field {
|
match field {
|
||||||
FieldsMember::Avatar => self.avatar = None,
|
FieldsMember::Avatar => self.avatar = None,
|
||||||
FieldsMember::Nickname => self.nickname = None,
|
FieldsMember::Nickname => self.nickname = None,
|
||||||
FieldsMember::Roles => self.roles.clear(),
|
FieldsMember::Roles => self.roles = None,
|
||||||
FieldsMember::Timeout => self.timeout = None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ use crate::{perms, Database, Error, Result};
|
|||||||
|
|
||||||
use futures::try_join;
|
use futures::try_join;
|
||||||
use impl_ops::impl_op_ex_commutative;
|
use impl_ops::impl_op_ex_commutative;
|
||||||
|
use okapi::openapi3::{SecurityScheme, SecuritySchemeData};
|
||||||
|
use rocket_okapi::gen::OpenApiGenerator;
|
||||||
|
use rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
impl_op_ex_commutative!(+ |a: &i32, b: &Badges| -> i32 { *a | *b as i32 });
|
impl_op_ex_commutative!(+ |a: &i32, b: &Badges| -> i32 { *a | *b as i32 });
|
||||||
@@ -150,51 +153,18 @@ impl User {
|
|||||||
Ok(db.fetch_server_count(&self.id).await? <= 100)
|
Ok(db.fetch_server_count(&self.id).await? <= 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sanitise and validate a username can be used
|
/// Update a user's username
|
||||||
pub async fn validate_username(db: &Database, username: String) -> Result<String> {
|
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
||||||
// Trim surrounding spaces
|
|
||||||
let username = username.trim().to_string();
|
let username = username.trim().to_string();
|
||||||
|
|
||||||
// Make sure username is still at least 3 characters
|
|
||||||
if username.len() < 2 {
|
|
||||||
return Err(Error::InvalidUsername);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the username for validation
|
|
||||||
let username_lowercase = username.to_lowercase();
|
|
||||||
|
|
||||||
// Ensure the username itself isn't blocked
|
|
||||||
const BLOCKED_USERNAMES: &[&str] = &["admin", "revolt"];
|
|
||||||
|
|
||||||
for username in BLOCKED_USERNAMES {
|
|
||||||
if username_lowercase == *username {
|
|
||||||
return Err(Error::InvalidUsername);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure none of the following substrings show up in the username
|
|
||||||
const BLOCKED_SUBSTRINGS: &[&str] = &["```"];
|
|
||||||
|
|
||||||
for substr in BLOCKED_SUBSTRINGS {
|
|
||||||
if username_lowercase.contains(substr) {
|
|
||||||
return Err(Error::InvalidUsername);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the username isn't taken
|
|
||||||
if db.is_username_taken(&username).await? {
|
if db.is_username_taken(&username).await? {
|
||||||
return Err(Error::UsernameTaken);
|
return Err(Error::UsernameTaken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(username)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update a user's username
|
|
||||||
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
|
||||||
self.update(
|
self.update(
|
||||||
db,
|
db,
|
||||||
PartialUser {
|
PartialUser {
|
||||||
username: Some(User::validate_username(db, username).await?),
|
username: Some(username),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
@@ -389,3 +359,72 @@ impl User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use rauth::entities::Session;
|
||||||
|
use rocket::http::Status;
|
||||||
|
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||||
|
|
||||||
|
#[rocket::async_trait]
|
||||||
|
impl<'r> FromRequest<'r> for User {
|
||||||
|
type Error = rauth::util::Error;
|
||||||
|
|
||||||
|
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||||
|
let user: &Option<User> = request
|
||||||
|
.local_cache_async(async {
|
||||||
|
let db = request
|
||||||
|
.rocket()
|
||||||
|
.state::<Database>()
|
||||||
|
.expect("Database state not reachable!");
|
||||||
|
|
||||||
|
let header_bot_token = request
|
||||||
|
.headers()
|
||||||
|
.get("x-bot-token")
|
||||||
|
.next()
|
||||||
|
.map(|x| x.to_string());
|
||||||
|
|
||||||
|
if let Some(bot_token) = header_bot_token {
|
||||||
|
if let Ok(user) = User::from_token(db, &bot_token, UserHint::Bot).await {
|
||||||
|
return Some(user);
|
||||||
|
}
|
||||||
|
} else if let Outcome::Success(session) = request.guard::<Session>().await {
|
||||||
|
// This uses a guard so can't really easily be refactored into from_token at this stage.
|
||||||
|
if let Ok(user) = db.fetch_user(&session.user_id).await {
|
||||||
|
return Some(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Some(user) = user {
|
||||||
|
Outcome::Success(user.clone())
|
||||||
|
} else {
|
||||||
|
Outcome::Failure((Status::Unauthorized, rauth::util::Error::InvalidSession))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'r> OpenApiFromRequest<'r> for User {
|
||||||
|
fn from_request_input(
|
||||||
|
_gen: &mut OpenApiGenerator,
|
||||||
|
_name: String,
|
||||||
|
_required: bool,
|
||||||
|
) -> rocket_okapi::Result<RequestHeaderInput> {
|
||||||
|
let mut requirements = schemars::Map::new();
|
||||||
|
requirements.insert("Api Key".to_owned(), vec![]);
|
||||||
|
|
||||||
|
Ok(RequestHeaderInput::Security(
|
||||||
|
"Api Key".to_owned(),
|
||||||
|
SecurityScheme {
|
||||||
|
data: SecuritySchemeData::ApiKey {
|
||||||
|
name: "x-session-token".to_owned(),
|
||||||
|
location: "header".to_owned(),
|
||||||
|
},
|
||||||
|
description: Some("Session Token".to_owned()),
|
||||||
|
extensions: schemars::Map::new(),
|
||||||
|
},
|
||||||
|
requirements,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
mod dummy;
|
pub mod dummy;
|
||||||
mod generic;
|
pub mod generic;
|
||||||
mod mongo;
|
pub mod mongo;
|
||||||
|
|
||||||
#[cfg(feature = "rocket_impl")]
|
|
||||||
mod rocket;
|
|
||||||
|
|
||||||
pub use self::generic::users::user_settings::UserSettingsImpl;
|
|
||||||
pub use dummy::DummyDb;
|
|
||||||
pub use mongo::MongoDb;
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use crate::r#impl::mongo::MongoDb;
|
|||||||
|
|
||||||
use super::scripts::LATEST_REVISION;
|
use super::scripts::LATEST_REVISION;
|
||||||
|
|
||||||
|
use log::info;
|
||||||
use mongodb::bson::doc;
|
use mongodb::bson::doc;
|
||||||
use mongodb::options::CreateCollectionOptions;
|
use mongodb::options::CreateCollectionOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bson::{Bson, DateTime};
|
use bson::Bson;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
use log::info;
|
||||||
use mongodb::{
|
use mongodb::{
|
||||||
bson::{doc, from_bson, from_document, to_document, Document},
|
bson::{doc, from_bson, from_document, to_document, Document},
|
||||||
options::FindOptions,
|
options::FindOptions,
|
||||||
@@ -16,7 +17,7 @@ struct MigrationInfo {
|
|||||||
revision: i32,
|
revision: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LATEST_REVISION: i32 = 18;
|
pub const LATEST_REVISION: i32 = 15;
|
||||||
|
|
||||||
pub async fn migrate_database(db: &MongoDb) {
|
pub async fn migrate_database(db: &MongoDb) {
|
||||||
let migrations = db.col::<Document>("migrations");
|
let migrations = db.col::<Document>("migrations");
|
||||||
@@ -602,65 +603,6 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if revision <= 15 {
|
|
||||||
info!("Running migration [revision 15 / 04-06-2022]: Migrate rAuth to latest version.");
|
|
||||||
|
|
||||||
let db = rauth::Database::MongoDb(rauth::database::MongoDb(db.db()));
|
|
||||||
db.run_migration(rauth::Migration::M2022_06_03EnsureUpToSpec)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if revision <= 16 {
|
|
||||||
info!("Running migration [revision 16 / 07-07-2022]: Add `emojis` collection and rAuth migration.");
|
|
||||||
|
|
||||||
let rauth_db = rauth::Database::MongoDb(rauth::database::MongoDb(db.db()));
|
|
||||||
rauth_db
|
|
||||||
.run_migration(rauth::Migration::M2022_06_09AddIndexForDeletion)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
db.db()
|
|
||||||
.create_collection("emojis", None)
|
|
||||||
.await
|
|
||||||
.expect("Failed to create emojis collection.");
|
|
||||||
|
|
||||||
db.db()
|
|
||||||
.run_command(
|
|
||||||
doc! {
|
|
||||||
"createIndexes": "emojis",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"key": {
|
|
||||||
"parent.id": 1_i32,
|
|
||||||
},
|
|
||||||
"name": "parent_id"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to create emoji parent index.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if revision <= 17 {
|
|
||||||
info!("Running migration [revision 17 / 15-07-2022]: Initialise `joined_at` property on server members.");
|
|
||||||
|
|
||||||
db.col::<Document>("server_members")
|
|
||||||
.update_many(
|
|
||||||
doc! {},
|
|
||||||
doc! {
|
|
||||||
"$set": {
|
|
||||||
"joined_at": DateTime::now().to_rfc3339_string()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to update server members.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Need to migrate fields on attachments, change `user_id`, `object_id`, etc to `parent`.
|
// Need to migrate fields on attachments, change `user_id`, `object_id`, etc to `parent`.
|
||||||
|
|
||||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||||
|
|||||||
@@ -122,27 +122,4 @@ impl AbstractAttachment for MongoDb {
|
|||||||
with: "attachment",
|
with: "attachment",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()> {
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.update_many(
|
|
||||||
doc! {
|
|
||||||
"_id": {
|
|
||||||
"$in": ids
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$set": {
|
|
||||||
"deleted": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update",
|
|
||||||
with: "attachments",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -37,46 +37,30 @@ impl AbstractChannelUnread for MongoDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn acknowledge_channels(&self, user: &str, channels: &[String]) -> Result<()> {
|
async fn acknowledge_channels(&self, user: &str, channels: &[String]) -> Result<()> {
|
||||||
let current_time = Ulid::new().to_string();
|
|
||||||
|
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.delete_many(
|
.update_one(
|
||||||
doc! {
|
doc! {
|
||||||
"_id.channel": {
|
"_id.channel": {
|
||||||
"$in": channels
|
"$in": channels
|
||||||
},
|
},
|
||||||
"_id.user": user
|
"_id.user": user,
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "delete_many",
|
|
||||||
with: "channel_unreads",
|
|
||||||
})?;
|
|
||||||
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.insert_many(
|
|
||||||
channels
|
|
||||||
.iter()
|
|
||||||
.map(|channel| {
|
|
||||||
doc! {
|
doc! {
|
||||||
"_id": {
|
"$unset": {
|
||||||
"channel": channel,
|
"mentions": 1_i32
|
||||||
"user": user
|
|
||||||
},
|
},
|
||||||
"last_id": ¤t_time
|
"$set": {
|
||||||
|
"last_id": Ulid::new().to_string()
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
.collect::<Vec<Document>>(),
|
UpdateOptions::builder().upsert(true).build(),
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_many",
|
|
||||||
with: "channel_unreads",
|
|
||||||
})
|
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
.map_err(|_| Error::DatabaseError {
|
||||||
|
operation: "update",
|
||||||
|
with: "channel_unread",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn add_mention_to_unread<'a>(
|
async fn add_mention_to_unread<'a>(
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ impl MongoDb {
|
|||||||
pub async fn delete_bulk_messages(&self, projection: Document) -> Result<()> {
|
pub async fn delete_bulk_messages(&self, projection: Document) -> Result<()> {
|
||||||
let mut for_attachments = projection.clone();
|
let mut for_attachments = projection.clone();
|
||||||
for_attachments.insert(
|
for_attachments.insert(
|
||||||
"attachments",
|
"attachment",
|
||||||
doc! {
|
doc! {
|
||||||
"$exists": 1_i32
|
"$exists": 1_i32
|
||||||
},
|
},
|
||||||
@@ -126,7 +126,10 @@ impl AbstractMessage for MongoDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_message(&self, id: &str) -> Result<()> {
|
async fn delete_message(&self, id: &str) -> Result<()> {
|
||||||
self.delete_one_by_id(COL, id).await.map(|_| ())
|
self.delete_bulk_messages(doc! {
|
||||||
|
"_id": id
|
||||||
|
})
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_messages(&self, channel: &str, ids: Vec<String>) -> Result<()> {
|
async fn delete_messages(&self, channel: &str, ids: Vec<String>) -> Result<()> {
|
||||||
@@ -279,70 +282,4 @@ impl AbstractMessage for MongoDb {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new reaction to a message
|
|
||||||
async fn add_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()> {
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": id
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$addToSet": {
|
|
||||||
format!("reactions.{emoji}"): user
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_one",
|
|
||||||
with: "message",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a reaction from a message
|
|
||||||
async fn remove_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()> {
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": id
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$pull": {
|
|
||||||
format!("reactions.{emoji}"): user
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_one",
|
|
||||||
with: "message",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove reaction from a message
|
|
||||||
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": id
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$unset": {
|
|
||||||
format!("reactions.{emoji}"): 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_one",
|
|
||||||
with: "message",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
use bson::Document;
|
|
||||||
|
|
||||||
use crate::models::Emoji;
|
|
||||||
use crate::{AbstractEmoji, Error, Result};
|
|
||||||
|
|
||||||
use super::super::MongoDb;
|
|
||||||
|
|
||||||
static COL: &str = "emojis";
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl AbstractEmoji for MongoDb {
|
|
||||||
/// Fetch an emoji by its id
|
|
||||||
async fn fetch_emoji(&self, id: &str) -> Result<Emoji> {
|
|
||||||
self.find_one_by_id(COL, id).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch emoji by their ids
|
|
||||||
async fn fetch_emoji_by_parent_id(&self, parent_id: &str) -> Result<Vec<Emoji>> {
|
|
||||||
self.find(
|
|
||||||
COL,
|
|
||||||
doc! {
|
|
||||||
"parent.id": parent_id
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch emoji by their parent ids
|
|
||||||
async fn fetch_emoji_by_parent_ids(&self, parent_ids: &[String]) -> Result<Vec<Emoji>> {
|
|
||||||
self.find(
|
|
||||||
COL,
|
|
||||||
doc! {
|
|
||||||
"parent.id": {
|
|
||||||
"$in": parent_ids
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert emoji into database.
|
|
||||||
async fn insert_emoji(&self, emoji: &Emoji) -> Result<()> {
|
|
||||||
self.insert_one(COL, emoji).await.map(|_| ())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Delete an emoji by its id
|
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": &emoji.id
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$set": {
|
|
||||||
"parent": {
|
|
||||||
"type": "Detached"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_one",
|
|
||||||
with: "emojis",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,8 @@ pub mod admin {
|
|||||||
pub mod migrations;
|
pub mod migrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod media {
|
pub mod autumn {
|
||||||
pub mod attachment;
|
pub mod attachment;
|
||||||
pub mod emoji;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod channels {
|
pub mod channels {
|
||||||
|
|||||||
@@ -18,20 +18,6 @@ impl MongoDb {
|
|||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Delete all emoji.
|
|
||||||
self.col::<Document>("emojis")
|
|
||||||
.delete_many(
|
|
||||||
doc! {
|
|
||||||
"parent.id": &server.id
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "delete_many",
|
|
||||||
with: "emojis",
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Delete all channels.
|
// Delete all channels.
|
||||||
self.col::<Document>("channels")
|
self.col::<Document>("channels")
|
||||||
.delete_many(
|
.delete_many(
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ impl IntoDocumentPath for FieldsMember {
|
|||||||
FieldsMember::Avatar => "avatar",
|
FieldsMember::Avatar => "avatar",
|
||||||
FieldsMember::Nickname => "nickname",
|
FieldsMember::Nickname => "nickname",
|
||||||
FieldsMember::Roles => "roles",
|
FieldsMember::Roles => "roles",
|
||||||
FieldsMember::Timeout => "timeout",
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
use okapi::openapi3::{SecurityScheme, SecuritySchemeData};
|
|
||||||
use rauth::models::Session;
|
|
||||||
use rocket_okapi::gen::OpenApiGenerator;
|
|
||||||
use rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
|
||||||
|
|
||||||
use rocket::http::Status;
|
|
||||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
|
||||||
|
|
||||||
use crate::models::user::UserHint;
|
|
||||||
use crate::models::User;
|
|
||||||
use crate::Database;
|
|
||||||
|
|
||||||
#[rocket::async_trait]
|
|
||||||
impl<'r> FromRequest<'r> for User {
|
|
||||||
type Error = rauth::Error;
|
|
||||||
|
|
||||||
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
|
||||||
let user: &Option<User> = request
|
|
||||||
.local_cache_async(async {
|
|
||||||
let db = request.rocket().state::<Database>().expect("`Database`");
|
|
||||||
|
|
||||||
let header_bot_token = request
|
|
||||||
.headers()
|
|
||||||
.get("x-bot-token")
|
|
||||||
.next()
|
|
||||||
.map(|x| x.to_string());
|
|
||||||
|
|
||||||
if let Some(bot_token) = header_bot_token {
|
|
||||||
if let Ok(user) = User::from_token(db, &bot_token, UserHint::Bot).await {
|
|
||||||
return Some(user);
|
|
||||||
}
|
|
||||||
} else if let Outcome::Success(session) = request.guard::<Session>().await {
|
|
||||||
// This uses a guard so can't really easily be refactored into from_token at this stage.
|
|
||||||
if let Ok(user) = db.fetch_user(&session.user_id).await {
|
|
||||||
return Some(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if let Some(user) = user {
|
|
||||||
Outcome::Success(user.clone())
|
|
||||||
} else {
|
|
||||||
Outcome::Failure((Status::Unauthorized, rauth::Error::InvalidSession))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'r> OpenApiFromRequest<'r> for User {
|
|
||||||
fn from_request_input(
|
|
||||||
_gen: &mut OpenApiGenerator,
|
|
||||||
_name: String,
|
|
||||||
_required: bool,
|
|
||||||
) -> rocket_okapi::Result<RequestHeaderInput> {
|
|
||||||
let mut requirements = schemars::Map::new();
|
|
||||||
requirements.insert("Session Token".to_owned(), vec![]);
|
|
||||||
|
|
||||||
Ok(RequestHeaderInput::Security(
|
|
||||||
"Session Token".to_owned(),
|
|
||||||
SecurityScheme {
|
|
||||||
data: SecuritySchemeData::ApiKey {
|
|
||||||
name: "x-session-token".to_owned(),
|
|
||||||
location: "header".to_owned(),
|
|
||||||
},
|
|
||||||
description: Some("Used to authenticate as a user.".to_owned()),
|
|
||||||
extensions: schemars::Map::new(),
|
|
||||||
},
|
|
||||||
requirements,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||