+ https://github.com/marmelab/react-admin/issues/4349#issuecomment-578594735
+ */
+
+ {record.quarantined_by && (
+
+
+ {/*
+ Button instead BooleanField for
+ consistent appearance and position in the column
+ */}
+
+
+
+ )}
+ {record.safe_from_quarantine && (
+
+
+
+
+
+ )}
+ {!record.safe_from_quarantine && !record.quarantined_by && (
+
+
+
+
+
+ )}
+
+ );
+};
diff --git a/src/components/users.js b/src/components/users.js
index 8e198c9..32cbdd6 100644
--- a/src/components/users.js
+++ b/src/components/users.js
@@ -1,13 +1,13 @@
import React, { cloneElement, Fragment } from "react";
import Avatar from "@material-ui/core/Avatar";
-import PersonPinIcon from "@material-ui/icons/PersonPin";
import AssignmentIndIcon from "@material-ui/icons/AssignmentInd";
import ContactMailIcon from "@material-ui/icons/ContactMail";
import DevicesIcon from "@material-ui/icons/Devices";
import GetAppIcon from "@material-ui/icons/GetApp";
-import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
import NotificationsIcon from "@material-ui/icons/Notifications";
import PermMediaIcon from "@material-ui/icons/PermMedia";
+import PersonPinIcon from "@material-ui/icons/PersonPin";
+import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
import ViewListIcon from "@material-ui/icons/ViewList";
import {
ArrayInput,
@@ -48,6 +48,7 @@ import {
import { Link } from "react-router-dom";
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
import { DeviceRemoveButton } from "./devices";
+import { ProtectMediaButton } from "./media";
import { makeStyles } from "@material-ui/core/styles";
const redirect = () => {
@@ -465,7 +466,7 @@ export const UserEdit = props => {
-
+
diff --git a/src/i18n/de.js b/src/i18n/de.js
index 7de0286..7a9139f 100644
--- a/src/i18n/de.js
+++ b/src/i18n/de.js
@@ -263,6 +263,15 @@ const de = {
send: "Diese API löscht die lokalen Medien von der Festplatte des eigenen Servers. Dies umfasst alle lokalen Miniaturbilder und Kopien von Medien. Diese API wirkt sich nicht auf Medien aus, die sich in externen Medien-Repositories befinden.",
},
},
+ protect_media: {
+ action: {
+ create: "Ungeschützt, Schutz erstellen",
+ delete: "Geschützt, Schutz aufheben",
+ none: "In Quarantäne",
+ send_success: "Erfolgreich den Schutz-Status geändert.",
+ send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
+ },
+ },
pushers: {
name: "Pusher |||| Pushers",
fields: {
diff --git a/src/i18n/en.js b/src/i18n/en.js
index b8f239e..680fcc5 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -259,6 +259,15 @@ const en = {
send: "This API deletes the local media from the disk of your own server. This includes any local thumbnails and copies of media downloaded. This API will not affect media that has been uploaded to external media repositories.",
},
},
+ protect_media: {
+ action: {
+ create: "Unprotected, create protection",
+ delete: "Protected, remove protection",
+ none: "In quarantine",
+ send_success: "Successfully changed the protection status.",
+ send_failure: "An error has occurred.",
+ },
+ },
pushers: {
name: "Pusher |||| Pushers",
fields: {
diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js
index 3bfa4e7..d40640a 100644
--- a/src/synapse/dataProvider.js
+++ b/src/synapse/dataProvider.js
@@ -182,6 +182,17 @@ const resourceMap = {
method: "POST",
}),
},
+ protect_media: {
+ map: pm => ({ id: pm.media_id }),
+ create: params => ({
+ endpoint: `/_synapse/admin/v1/media/protect/${params.media_id}`,
+ method: "POST",
+ }),
+ delete: params => ({
+ endpoint: `/_synapse/admin/v1/media/unprotect/${params.media_id}`,
+ method: "POST",
+ }),
+ },
servernotices: {
map: n => ({ id: n.event_id }),
create: data => ({
From 865fc98336a1505f268065f8d85dd8e2452903df Mon Sep 17 00:00:00 2001
From: csett86
Date: Thu, 19 Aug 2021 12:12:27 +0200
Subject: [PATCH 09/13] Add github action that packages a release tarball
(#148)
Change-Id: I368a834a27f69550596a041c1e6b84afd40011b7
---
.github/workflows/github-release.yml | 28 ++++++++++++++++++++++++++++
README.md | 18 ++++++++++++++----
2 files changed, 42 insertions(+), 4 deletions(-)
create mode 100644 .github/workflows/github-release.yml
diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml
new file mode 100644
index 0000000..02a8d2c
--- /dev/null
+++ b/.github/workflows/github-release.yml
@@ -0,0 +1,28 @@
+name: Create release tarball and attach to tag
+
+on:
+ push:
+ tags:
+ - "*"
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2
+ with:
+ node-version: "14"
+ - run: yarn install
+ - run: yarn build
+ - run: |
+ version=`git describe --dirty --tags || echo unknown`
+ mkdir -p dist
+ cp -r build synapse-admin-$version
+ tar chvzf dist/synapse-admin-$version.tar.gz synapse-admin-$version
+ - uses: softprops/action-gh-release@b7e450da2a4b4cb4bfbae528f788167786cfcedf
+ with:
+ files: dist/*.tar.gz
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/README.md b/README.md
index e6c9780..96ab28c 100644
--- a/README.md
+++ b/README.md
@@ -21,13 +21,23 @@ See also [Synapse administration endpoints](https://matrix-org.github.io/synapse
## Step-By-Step install:
-You have two options:
+You have three options:
-1. Download the source code from github and run using nodejs
-2. Run the Docker container
+1. Download the tarball and serve with any webserver
+2. Download the source code from github and run using nodejs
+3. Run the Docker container
Steps for 1):
+- make sure you have a webserver installed that can serve static files (any webserver like nginx or apache will do)
+- configure a vhost for synapse admin on your webserver
+- download the .tar.gz from the latest release: https://github.com/Awesome-Technologies/synapse-admin/releases/latest
+- unpack the .tar.gz
+- move or symlink the `synapse-admin-x.x.x` into your vhosts root dir
+- open the url of the vhost in your browser
+
+Steps for 2):
+
- make sure you have installed the following: git, yarn, nodejs
- download the source code: `git clone https://github.com/Awesome-Technologies/synapse-admin.git`
- change into downloaded directory: `cd synapse-admin`
@@ -39,7 +49,7 @@ Either you define it at startup (e.g. `REACT_APP_SERVER=https://yourmatrixserver
or by editing it in the [.env](.env) file. See also the
[documentation](https://create-react-app.dev/docs/adding-custom-environment-variables/).
-Steps for 2):
+Steps for 3):
- run the Docker container from the public docker registry: `docker run -p 8080:80 awesometechnologies/synapse-admin` or use the [docker-compose.yml](docker-compose.yml): `docker-compose up -d`
From 28862035943290d4d26cf111d1a2a405db93680d Mon Sep 17 00:00:00 2001
From: Manuel Stahl
Date: Tue, 24 Aug 2021 10:44:17 +0200
Subject: [PATCH 10/13] Add github action that builds docker images and pushes
them to docker hub
Change-Id: I60d39cc266c2e8b905e2ac4a367bd5a22b79b57b
---
.github/workflows/docker-release.yml | 36 ++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 .github/workflows/docker-release.yml
diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml
new file mode 100644
index 0000000..5423259
--- /dev/null
+++ b/.github/workflows/docker-release.yml
@@ -0,0 +1,36 @@
+name: Create docker image(s) and push to docker hub
+
+on:
+ push:
+ tags:
+ - '[0-9]+\.[0-9]+\.[0-9]+'
+
+jobs:
+ docker:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ - name: Build and push
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: awesometechnologies/synapse-admin:latest
+ - name: Update repo description
+ uses: peter-evans/dockerhub-description@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ repository: awesometechnologies/synapse-admin
From aaf782d24fade4b4f8cb9c5152345e36f3eccffd Mon Sep 17 00:00:00 2001
From: Manuel Stahl
Date: Tue, 24 Aug 2021 15:07:11 +0200
Subject: [PATCH 11/13] Use .gitignore for prettier as well
Change-Id: Ibfe73812a5375cc251b859b8aa441583c0cdcd41
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 8961456..4ddb1ff 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
"fix:other": "yarn prettier --write",
"fix:code": "yarn test:lint --fix",
"fix": "yarn fix:code && yarn fix:other",
- "prettier": "prettier \"**/*.{js,jsx,json,md,scss,yaml,yml}\"",
+ "prettier": "prettier --ignore-path .gitignore \"**/*.{js,jsx,json,md,scss,yaml,yml}\"",
"test:code": "react-scripts test",
"test:lint": "eslint --ignore-path .gitignore --ext .js,.jsx .",
"test:style": "yarn prettier --list-different",
From 8536f552d4dce1e277c83c92b86c8d9fedbcbaad Mon Sep 17 00:00:00 2001
From: dklimpel <5740567+dklimpel@users.noreply.github.com>
Date: Thu, 19 Aug 2021 13:51:53 +0200
Subject: [PATCH 12/13] Add button to quarantine media (#180)
Change-Id: I6496826fdf75ab8b7b3ed5a9056abf86a50caea3
---
src/components/media.js | 84 +++++++++++++++++++++++++++++++++++++
src/components/users.js | 3 +-
src/i18n/de.js | 12 +++++-
src/i18n/en.js | 10 +++++
src/synapse/dataProvider.js | 15 +++++++
5 files changed, 122 insertions(+), 2 deletions(-)
diff --git a/src/components/media.js b/src/components/media.js
index 095f1ad..a523fa2 100644
--- a/src/components/media.js
+++ b/src/components/media.js
@@ -17,6 +17,7 @@ import {
useRefresh,
useTranslate,
} from "react-admin";
+import BlockIcon from "@material-ui/icons/Block";
import ClearIcon from "@material-ui/icons/Clear";
import DeleteSweepIcon from "@material-ui/icons/DeleteSweep";
import Dialog from "@material-ui/core/Dialog";
@@ -241,3 +242,86 @@ export const ProtectMediaButton = props => {
);
};
+
+export const QuarantineMediaButton = props => {
+ const { record } = props;
+ const translate = useTranslate();
+ const refresh = useRefresh();
+ const notify = useNotify();
+ const [create, { loading }] = useCreate("quarantine_media");
+ const [deleteOne] = useDelete("quarantine_media");
+
+ if (!record) return null;
+
+ const handleQuarantaine = () => {
+ create(
+ { payload: { data: record } },
+ {
+ onSuccess: () => {
+ notify("resources.quarantine_media.action.send_success");
+ refresh();
+ },
+ onFailure: () =>
+ notify("resources.quarantine_media.action.send_failure", "error"),
+ }
+ );
+ };
+
+ const handleRemoveQuarantaine = () => {
+ deleteOne(
+ { payload: { ...record } },
+ {
+ onSuccess: () => {
+ notify("resources.quarantine_media.action.send_success");
+ refresh();
+ },
+ onFailure: () =>
+ notify("resources.quarantine_media.action.send_failure", "error"),
+ }
+ );
+ };
+
+ return (
+
+ {record.safe_from_quarantine && (
+
+
+
+
+
+ )}
+ {record.quarantined_by && (
+
+
+
+
+
+ )}
+ {!record.safe_from_quarantine && !record.quarantined_by && (
+
+
+
+
+
+ )}
+
+ );
+};
diff --git a/src/components/users.js b/src/components/users.js
index 32cbdd6..c954416 100644
--- a/src/components/users.js
+++ b/src/components/users.js
@@ -48,7 +48,7 @@ import {
import { Link } from "react-router-dom";
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
import { DeviceRemoveButton } from "./devices";
-import { ProtectMediaButton } from "./media";
+import { ProtectMediaButton, QuarantineMediaButton } from "./media";
import { makeStyles } from "@material-ui/core/styles";
const redirect = () => {
@@ -466,6 +466,7 @@ export const UserEdit = props => {
+
diff --git a/src/i18n/de.js b/src/i18n/de.js
index 7a9139f..f7b0bb1 100644
--- a/src/i18n/de.js
+++ b/src/i18n/de.js
@@ -242,7 +242,7 @@ const de = {
media_type: "Typ",
upload_name: "Dateiname",
quarantined_by: "Zur Quarantäne hinzugefügt",
- safe_from_quarantine: "Geschützt vor Quarantäne",
+ safe_from_quarantine: "Schutz vor Quarantäne",
created_ts: "Erstellt",
last_access_ts: "Letzter Zugriff",
},
@@ -272,6 +272,16 @@ const de = {
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
},
},
+ quarantine_media: {
+ action: {
+ name: "Quarantäne",
+ create: "Zur Quarantäne hinzufügen",
+ delete: "In Quarantäne, Quarantäne aufheben",
+ none: "Geschützt vor Quarantäne",
+ send_success: "Erfolgreich den Quarantäne-Status geändert.",
+ send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
+ },
+ },
pushers: {
name: "Pusher |||| Pushers",
fields: {
diff --git a/src/i18n/en.js b/src/i18n/en.js
index 680fcc5..e669a1a 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -268,6 +268,16 @@ const en = {
send_failure: "An error has occurred.",
},
},
+ quarantine_media: {
+ action: {
+ name: "Quarantine",
+ create: "Add to quarantine",
+ delete: "In quarantine, unquarantine",
+ none: "Protected from quarantine",
+ send_success: "Successfully changed the quarantine status.",
+ send_failure: "An error has occurred.",
+ },
+ },
pushers: {
name: "Pusher |||| Pushers",
fields: {
diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js
index d40640a..b37af45 100644
--- a/src/synapse/dataProvider.js
+++ b/src/synapse/dataProvider.js
@@ -193,6 +193,21 @@ const resourceMap = {
method: "POST",
}),
},
+ quarantine_media: {
+ map: qm => ({ id: qm.media_id }),
+ create: params => ({
+ endpoint: `/_synapse/admin/v1/media/quarantine/${localStorage.getItem(
+ "home_server"
+ )}/${params.media_id}`,
+ method: "POST",
+ }),
+ delete: params => ({
+ endpoint: `/_synapse/admin/v1/media/unquarantine/${localStorage.getItem(
+ "home_server"
+ )}/${params.media_id}`,
+ method: "POST",
+ }),
+ },
servernotices: {
map: n => ({ id: n.event_id }),
create: data => ({
From 9c36ed6566460369e1c077335a9eeec3df8bbe1e Mon Sep 17 00:00:00 2001
From: Manuel Stahl
Date: Wed, 25 Aug 2021 09:41:22 +0200
Subject: [PATCH 13/13] Increment version
Change-Id: I48fb812632dc2e498ad267477809a16fc882cf4c
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 4ddb1ff..393a41f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "synapse-admin",
- "version": "0.8.2",
+ "version": "0.8.3",
"description": "Admin GUI for the Matrix.org server Synapse",
"author": "Awesome Technologies Innovationslabor GmbH",
"license": "Apache-2.0",