Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fe63e3955 | ||
|
|
4474061103 | ||
|
|
788580a64f | ||
|
|
1303dbc844 | ||
|
|
7981748b7b | ||
|
|
53277cb235 | ||
|
|
92c7f023b1 | ||
|
|
839d7d0d9a | ||
|
|
ea8784215d | ||
|
|
084c635e9c | ||
|
|
924398df1d | ||
|
|
c204288b76 | ||
|
|
dcee48c69f | ||
|
|
c6efe3b190 | ||
|
|
13ed849657 | ||
|
|
08c1aa6f5d |
@@ -101,41 +101,3 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf /tmp/.buildx-cache
|
rm -rf /tmp/.buildx-cache
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
publish_arm64:
|
|
||||||
needs: [test]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags')
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: revoltchat/server, ghcr.io/revoltchat/server
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
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 }}
|
|
||||||
- name: Build and publish
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
platforms: linux/arm64
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
name: Add Issue to Board
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
track_issue:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Get project data
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
query {
|
||||||
|
organization(login: "revoltchat"){
|
||||||
|
projectNext(number: 3) {
|
||||||
|
id
|
||||||
|
fields(first:20) {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'TODO_OPTION_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Todo") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Add issue to project
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||||
|
run: |
|
||||||
|
item_id="$( gh api graphql -f query='
|
||||||
|
mutation($project:ID!, $issue:ID!) {
|
||||||
|
addProjectNextItem(input: {projectId: $project, contentId: $issue}) {
|
||||||
|
projectNextItem {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
|
||||||
|
|
||||||
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
name: Add PR to Board
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
track_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Get project data
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
query {
|
||||||
|
organization(login: "revoltchat"){
|
||||||
|
projectNext(number: 3) {
|
||||||
|
id
|
||||||
|
fields(first:20) {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'INCOMING_OPTION_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Incoming PRs") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Add PR to project
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
PR_ID: ${{ github.event.pull_request.node_id }}
|
||||||
|
run: |
|
||||||
|
item_id="$( gh api graphql -f query='
|
||||||
|
mutation($project:ID!, $pr:ID!) {
|
||||||
|
addProjectNextItem(input: {projectId: $project, contentId: $pr}) {
|
||||||
|
projectNextItem {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f pr=$PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
|
||||||
|
|
||||||
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set fields
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
mutation (
|
||||||
|
$project: ID!
|
||||||
|
$item: ID!
|
||||||
|
$status_field: ID!
|
||||||
|
$status_value: String!
|
||||||
|
) {
|
||||||
|
set_status: updateProjectNextItemField(input: {
|
||||||
|
projectId: $project
|
||||||
|
itemId: $item
|
||||||
|
fieldId: $status_field
|
||||||
|
value: $status_value
|
||||||
|
}) {
|
||||||
|
projectNextItem {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.INCOMING_OPTION_ID }} --silent
|
||||||
Generated
+1
-1
@@ -2577,7 +2577,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rauth"
|
name = "rauth"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/insertish/rauth?rev=775a6f3ffb9ffc0e382af32fac2924e9a707e890#775a6f3ffb9ffc0e382af32fac2924e9a707e890"
|
source = "git+https://github.com/insertish/rauth?rev=157263ffcbd6cb1073e288b215db227634c4c29a#157263ffcbd6cb1073e288b215db227634c4c29a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"base32",
|
"base32",
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ async-std = { version = "1.8.0", features = ["tokio1", "tokio02", "attributes"]
|
|||||||
web-push = "0.7.2"
|
web-push = "0.7.2"
|
||||||
many-to-many = "0.1.2"
|
many-to-many = "0.1.2"
|
||||||
lettre = "0.10.0-alpha.4"
|
lettre = "0.10.0-alpha.4"
|
||||||
rauth = { git = "https://github.com/insertish/rauth", rev = "775a6f3ffb9ffc0e382af32fac2924e9a707e890" }
|
rauth = { git = "https://github.com/insertish/rauth", rev = "157263ffcbd6cb1073e288b215db227634c4c29a" }
|
||||||
hive_pubsub = { git = "https://gitlab.insrt.uk/insert/hive", rev = "b0f3db9d33990530d7640d4bbb309c8d9eb5c0cf", features = ["redis-backend"] }
|
hive_pubsub = { git = "https://gitlab.insrt.uk/insert/hive", rev = "b0f3db9d33990530d7640d4bbb309c8d9eb5c0cf", features = ["redis-backend"] }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export version=0.5.3-alpha.7
|
export version=0.5.3-alpha.11
|
||||||
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::util::variables::{USE_JANUARY, PUBLIC_URL};
|
use crate::util::variables::{USE_JANUARY, PUBLIC_URL, APP_URL};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::*,
|
database::*,
|
||||||
notifications::{events::ClientboundNotification, websocket::is_online},
|
notifications::{events::ClientboundNotification, websocket::is_online},
|
||||||
@@ -9,6 +9,8 @@ use mongodb::bson::{doc, to_bson, DateTime};
|
|||||||
use rocket::serde::json::Value;
|
use rocket::serde::json::Value;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
use validator::Validate;
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -20,6 +22,7 @@ pub struct PushNotification {
|
|||||||
pub body: String,
|
pub body: String,
|
||||||
pub tag: String,
|
pub tag: String,
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PushNotification {
|
impl PushNotification {
|
||||||
@@ -63,6 +66,7 @@ impl PushNotification {
|
|||||||
body,
|
body,
|
||||||
tag: channel.id().to_string(),
|
tag: channel.id().to_string(),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
url: format!("{}/channel/{}/{}", *APP_URL, channel.id(), msg.id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,6 +127,7 @@ impl Content {
|
|||||||
target.id().to_string(),
|
target.id().to_string(),
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
.publish(&target, false)
|
.publish(&target, false)
|
||||||
@@ -130,6 +135,16 @@ impl Content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, Validate)]
|
||||||
|
pub struct Masquerade {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
#[validate(length(min = 1, max = 32))]
|
||||||
|
name: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
#[validate(length(min = 1, max = 128))]
|
||||||
|
avatar: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
#[serde(rename = "_id")]
|
#[serde(rename = "_id")]
|
||||||
@@ -149,7 +164,9 @@ pub struct Message {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub mentions: Option<Vec<String>>,
|
pub mentions: Option<Vec<String>>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub replies: Option<Vec<String>>
|
pub replies: Option<Vec<String>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub masquerade: Option<Masquerade>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
@@ -159,6 +176,7 @@ impl Message {
|
|||||||
content: Content,
|
content: Content,
|
||||||
mentions: Option<Vec<String>>,
|
mentions: Option<Vec<String>>,
|
||||||
replies: Option<Vec<String>>,
|
replies: Option<Vec<String>>,
|
||||||
|
masquerade: Option<Masquerade>,
|
||||||
) -> Message {
|
) -> Message {
|
||||||
Message {
|
Message {
|
||||||
id: Ulid::new().to_string(),
|
id: Ulid::new().to_string(),
|
||||||
@@ -170,7 +188,8 @@ impl Message {
|
|||||||
edited: None,
|
edited: None,
|
||||||
embeds: None,
|
embeds: None,
|
||||||
mentions,
|
mentions,
|
||||||
replies
|
replies,
|
||||||
|
masquerade
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,4 +341,23 @@ impl Message {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_associated_user_ids(&self, ids: &mut HashSet<String>) {
|
||||||
|
ids.insert(self.author.clone());
|
||||||
|
|
||||||
|
if let Content::SystemMessage(sys) = &self.content {
|
||||||
|
match sys {
|
||||||
|
SystemMessage::Text { .. } => {},
|
||||||
|
SystemMessage::UserAdded { id, by } => { ids.insert(id.clone()); ids.insert(by.clone()); },
|
||||||
|
SystemMessage::UserRemove { id, by } => { ids.insert(id.clone()); ids.insert(by.clone()); },
|
||||||
|
SystemMessage::UserJoined { id } => { ids.insert(id.clone()); },
|
||||||
|
SystemMessage::UserLeft { id } => { ids.insert(id.clone()); },
|
||||||
|
SystemMessage::UserKicked { id } => { ids.insert(id.clone()); },
|
||||||
|
SystemMessage::UserBanned { id } => { ids.insert(id.clone()); },
|
||||||
|
SystemMessage::ChannelRenamed { by, .. } => { ids.insert(by.clone()); },
|
||||||
|
SystemMessage::ChannelDescriptionChanged { by } => { ids.insert(by.clone()); },
|
||||||
|
SystemMessage::ChannelIconChanged { by } => { ids.insert(by.clone()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,12 @@ pub enum Badges {
|
|||||||
Translator = 2,
|
Translator = 2,
|
||||||
Supporter = 4,
|
Supporter = 4,
|
||||||
ResponsibleDisclosure = 8,
|
ResponsibleDisclosure = 8,
|
||||||
RevoltTeam = 16,
|
Founder = 16,
|
||||||
|
PlatformModeration = 32,
|
||||||
|
ActiveSupporter = 64,
|
||||||
|
Paw = 128,
|
||||||
EarlyAdopter = 256,
|
EarlyAdopter = 256,
|
||||||
|
ReservedRelevantJokeBadge1 = 512
|
||||||
}
|
}
|
||||||
|
|
||||||
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 });
|
||||||
|
|||||||
@@ -102,6 +102,19 @@ pub async fn create_database() {
|
|||||||
"content": "text"
|
"content": "text"
|
||||||
},
|
},
|
||||||
"name": "content"
|
"name": "content"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"channel": 1
|
||||||
|
},
|
||||||
|
"name": "channel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"channel": 1,
|
||||||
|
"_id": 1
|
||||||
|
},
|
||||||
|
"name": "channel_id_compound"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -110,6 +123,56 @@ pub async fn create_database() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create message index.");
|
.expect("Failed to create message index.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "channel_unreads",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.channel": 1,
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "compound_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create channel_unreads index.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "server_members",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.server": 1,
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "compound_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create server_members index.");
|
||||||
|
|
||||||
db.collection("migrations")
|
db.collection("migrations")
|
||||||
.insert_one(
|
.insert_one(
|
||||||
doc! {
|
doc! {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct MigrationInfo {
|
|||||||
revision: i32,
|
revision: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LATEST_REVISION: i32 = 10;
|
pub const LATEST_REVISION: i32 = 13;
|
||||||
|
|
||||||
pub async fn migrate_database() {
|
pub async fn migrate_database() {
|
||||||
let migrations = get_collection("migrations");
|
let migrations = get_collection("migrations");
|
||||||
@@ -372,6 +372,101 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if revision <= 11 {
|
||||||
|
info!("Running migration [revision 11 / 2021-11-14]: Add indexes to database.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "messages",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"channel": 1
|
||||||
|
},
|
||||||
|
"name": "channel"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create message index.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "channel_unreads",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.channel": 1,
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "compound_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create channel_unreads index.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "server_members",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.server": 1,
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "compound_id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"_id.user": 1,
|
||||||
|
},
|
||||||
|
"name": "user_id"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create server_members index.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if revision <= 12 {
|
||||||
|
info!("Running migration [revision 12 / 2021-11-21]: Add indexes to database.");
|
||||||
|
|
||||||
|
get_db()
|
||||||
|
.run_command(
|
||||||
|
doc! {
|
||||||
|
"createIndexes": "messages",
|
||||||
|
"indexes": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"channel": 1,
|
||||||
|
"_id": 1
|
||||||
|
},
|
||||||
|
"name": "channel_id_compound"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create message index.");
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ pub enum ChannelPermission {
|
|||||||
InviteOthers = 0b00000000000000000000000000100000, // 32
|
InviteOthers = 0b00000000000000000000000000100000, // 32
|
||||||
EmbedLinks = 0b00000000000000000000000001000000, // 64
|
EmbedLinks = 0b00000000000000000000000001000000, // 64
|
||||||
UploadFiles = 0b00000000000000000000000010000000, // 128
|
UploadFiles = 0b00000000000000000000000010000000, // 128
|
||||||
|
Masquerade = 0b00000000000000000000000100000000, // 256
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -27,7 +28,8 @@ lazy_static! {
|
|||||||
+ ChannelPermission::VoiceCall
|
+ ChannelPermission::VoiceCall
|
||||||
+ ChannelPermission::InviteOthers
|
+ ChannelPermission::InviteOthers
|
||||||
+ ChannelPermission::EmbedLinks
|
+ ChannelPermission::EmbedLinks
|
||||||
+ ChannelPermission::UploadFiles;
|
+ ChannelPermission::UploadFiles
|
||||||
|
+ ChannelPermission::Masquerade;
|
||||||
|
|
||||||
pub static ref DEFAULT_PERMISSION_SERVER: u32 =
|
pub static ref DEFAULT_PERMISSION_SERVER: u32 =
|
||||||
ChannelPermission::View
|
ChannelPermission::View
|
||||||
@@ -52,6 +54,7 @@ bitfield! {
|
|||||||
pub get_invite_others, _: 26;
|
pub get_invite_others, _: 26;
|
||||||
pub get_embed_links, _: 25;
|
pub get_embed_links, _: 25;
|
||||||
pub get_upload_files, _: 24;
|
pub get_upload_files, _: 24;
|
||||||
|
pub get_masquerade, _: 23;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PermissionCalculator<'a> {
|
impl<'a> PermissionCalculator<'a> {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ pub async fn req(user: User, target: Ref, options: Options) -> Result<Value> {
|
|||||||
if options.include_users.unwrap_or_else(|| false) {
|
if options.include_users.unwrap_or_else(|| false) {
|
||||||
let mut ids = HashSet::new();
|
let mut ids = HashSet::new();
|
||||||
for message in &messages {
|
for message in &messages {
|
||||||
ids.insert(message.author.clone());
|
message.add_associated_user_ids(&mut ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
ids.remove(&user.id);
|
ids.remove(&user.id);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ pub async fn req(user: User, target: Ref, options: Json<Options>) -> Result<Valu
|
|||||||
if options.include_users.unwrap_or_else(|| false) {
|
if options.include_users.unwrap_or_else(|| false) {
|
||||||
let mut ids = HashSet::new();
|
let mut ids = HashSet::new();
|
||||||
for message in &messages {
|
for message in &messages {
|
||||||
ids.insert(message.author.clone());
|
message.add_associated_user_ids(&mut ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
ids.remove(&user.id);
|
ids.remove(&user.id);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ pub struct Data {
|
|||||||
attachments: Option<Vec<String>>,
|
attachments: Option<Vec<String>>,
|
||||||
nonce: Option<String>,
|
nonce: Option<String>,
|
||||||
replies: Option<Vec<Reply>>,
|
replies: Option<Vec<Reply>>,
|
||||||
|
#[validate]
|
||||||
|
masquerade: Option<Masquerade>
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -62,11 +64,17 @@ pub async fn message_send(user: User, _r: Ratelimiter, mut idempotency: Idempote
|
|||||||
|
|
||||||
let mut mentions = HashSet::new();
|
let mut mentions = HashSet::new();
|
||||||
for capture in RE_MENTION.captures_iter(&message.content) {
|
for capture in RE_MENTION.captures_iter(&message.content) {
|
||||||
if let Some(mention) = capture.get(1) {
|
if let Some(mention) = capture.get(1) {
|
||||||
mentions.insert(mention.as_str().to_string());
|
mentions.insert(mention.as_str().to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(_) = &message.masquerade {
|
||||||
|
if !perm.get_masquerade() {
|
||||||
|
return Err(Error::MissingPermission)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut replies = HashSet::new();
|
let mut replies = HashSet::new();
|
||||||
if let Some(entries) = message.replies {
|
if let Some(entries) = message.replies {
|
||||||
// ! FIXME: move this to app config
|
// ! FIXME: move this to app config
|
||||||
@@ -127,6 +135,7 @@ pub async fn message_send(user: User, _r: Ratelimiter, mut idempotency: Idempote
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
masquerade: message.masquerade
|
||||||
};
|
};
|
||||||
|
|
||||||
msg.clone().publish(&target, perm.get_embed_links()).await?;
|
msg.clone().publish(&target, perm.get_embed_links()).await?;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub async fn run() {
|
|||||||
if let Ok(mut cursor) = Session::find(
|
if let Ok(mut cursor) = Session::find(
|
||||||
&get_db(),
|
&get_db(),
|
||||||
doc! {
|
doc! {
|
||||||
"_id": {
|
"user_id": {
|
||||||
"$in": recipients
|
"$in": recipients
|
||||||
},
|
},
|
||||||
"subscription": {
|
"subscription": {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
pub const VERSION: &str = "0.5.3-alpha.7";
|
pub const VERSION: &str = "0.5.3-alpha.11";
|
||||||
|
|||||||
Reference in New Issue
Block a user