diff --git a/src/App.js b/src/App.js
index 238d13b..f943e3f 100644
--- a/src/App.js
+++ b/src/App.js
@@ -37,6 +37,7 @@ const App = () => (
/>
+
);
diff --git a/src/components/ServerNotices.js b/src/components/ServerNotices.js
new file mode 100644
index 0000000..a0f37da
--- /dev/null
+++ b/src/components/ServerNotices.js
@@ -0,0 +1,100 @@
+import React, { Fragment, useState } from "react";
+import {
+ Button,
+ SaveButton,
+ SimpleForm,
+ TextInput,
+ Toolbar,
+ required,
+ useCreate,
+ useNotify,
+ useTranslate,
+} from "react-admin";
+import MessageIcon from "@material-ui/icons/Message";
+import IconCancel from "@material-ui/icons/Cancel";
+import Dialog from "@material-ui/core/Dialog";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogContentText from "@material-ui/core/DialogContentText";
+import DialogTitle from "@material-ui/core/DialogTitle";
+
+const ServerNoticeDialog = ({ open, loading, onClose, onSend }) => {
+ const translate = useTranslate();
+
+ const ServerNoticeToolbar = props => (
+
+
+
+
+ );
+
+ return (
+
+ );
+};
+
+export const ServerNoticeButton = ({ record }) => {
+ const [open, setOpen] = useState(false);
+ const notify = useNotify();
+ const [create, { loading }] = useCreate("servernotices");
+
+ const handleDialogOpen = () => setOpen(true);
+ const handleDialogClose = () => setOpen(false);
+
+ const handleSend = values => {
+ create(
+ { payload: { data: { id: record.id, ...values } } },
+ {
+ onSuccess: () => {
+ notify("resources.servernotices.action.send_success");
+ handleDialogClose();
+ },
+ onFailure: () =>
+ notify("resources.servernotices.action.send_failure", "error"),
+ }
+ );
+ };
+
+ return (
+
+
+
+
+ );
+};
diff --git a/src/components/users.js b/src/components/users.js
index 3674127..8e6c75b 100644
--- a/src/components/users.js
+++ b/src/components/users.js
@@ -30,6 +30,7 @@ import {
useTranslate,
Pagination,
} from "react-admin";
+import { ServerNoticeButton } from "./ServerNotices";
const UserPagination = props => (
@@ -108,6 +109,7 @@ const UserEditToolbar = props => {
label="resources.users.action.erase"
title={translate("resources.users.helper.erase")}
/>
+
);
};
diff --git a/src/i18n/de.js b/src/i18n/de.js
index 9871a89..a467c1a 100644
--- a/src/i18n/de.js
+++ b/src/i18n/de.js
@@ -63,6 +63,22 @@ export default {
user_agent: "User Agent",
},
},
+ servernotices: {
+ name: "Serverbenachrichtigungen",
+ send: "Servernachricht versenden",
+ fields: {
+ body: "Nachricht",
+ },
+ action: {
+ send: "Sende Nachricht",
+ send_success: "Nachricht erfolgreich versendet.",
+ send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
+ },
+ helper: {
+ send:
+ 'Sendet eine Serverbenachrichtigung an die ausgewählten Nutzer. Hierfür muss das Feature "Server Notices" auf dem Server aktiviert sein.',
+ },
+ },
},
ra: {
...germanMessages.ra,
diff --git a/src/i18n/en.js b/src/i18n/en.js
index ff0864a..a7a6141 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -63,5 +63,21 @@ export default {
user_agent: "User agent",
},
},
+ servernotices: {
+ name: "Server Notices",
+ send: "Send server notices",
+ fields: {
+ body: "Message",
+ },
+ action: {
+ send: "Send note",
+ send_success: "Server notice successfully sent.",
+ send_failure: "An error has occurred.",
+ },
+ helper: {
+ send:
+ 'Sends a server notice to the selected users. The feature "Server Notices" has to be activated at the server.',
+ },
+ },
},
};
diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js
index 7a1500a..859dc73 100644
--- a/src/synapse/dataProvider.js
+++ b/src/synapse/dataProvider.js
@@ -62,6 +62,20 @@ const resourceMap = {
}),
data: "connections",
},
+ servernotices: {
+ map: n => ({ id: n.event_id }),
+ create: data => ({
+ endpoint: "/_synapse/admin/v1/send_server_notice",
+ body: {
+ user_id: data.id,
+ content: {
+ msgtype: "m.text",
+ body: data.body,
+ },
+ },
+ method: "POST",
+ }),
+ },
};
function filterNullValues(key, value) {