Add view of reported events (#84)

This commit is contained in:
Dirk Klimpel 2021-01-04 09:14:33 +01:00 committed by GitHub
parent 1706cd3c9d
commit 2f96951c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 204 additions and 2 deletions

View file

@ -4,7 +4,7 @@
This project is built using [react-admin](https://marmelab.com/react-admin/).
It needs at least Synapse v1.18.0 for all functions to work as expected!
It needs at least Synapse v1.23.0 for all functions to work as expected!
You get your server version with the request `/_synapse/admin/v1/server_version`.
See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst).

View file

@ -5,9 +5,11 @@ import authProvider from "./synapse/authProvider";
import dataProvider from "./synapse/dataProvider";
import { UserList, UserCreate, UserEdit } from "./components/users";
import { RoomList, RoomShow } from "./components/rooms";
import { ReportList, ReportShow } from "./components/EventReports";
import LoginPage from "./components/LoginPage";
import UserIcon from "@material-ui/icons/Group";
import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList";
import RoomIcon from "@material-ui/icons/ViewList";
import ReportIcon from "@material-ui/icons/Warning";
import { ImportFeature } from "./components/ImportFeature";
import { Route } from "react-router-dom";
import germanMessages from "./i18n/de";
@ -41,6 +43,12 @@ const App = () => (
icon={UserIcon}
/>
<Resource name="rooms" list={RoomList} show={RoomShow} icon={RoomIcon} />
<Resource
name="reports"
list={ReportList}
show={ReportShow}
icon={ReportIcon}
/>
<Resource name="connections" />
<Resource name="devices" />
<Resource name="room_members" />

View file

@ -0,0 +1,135 @@
import React from "react";
import {
Datagrid,
DateField,
List,
NumberField,
Pagination,
ReferenceField,
Show,
Tab,
TabbedShowLayout,
TextField,
useTranslate,
} from "react-admin";
import PageviewIcon from "@material-ui/icons/Pageview";
import ViewListIcon from "@material-ui/icons/ViewList";
const ReportPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
);
export const ReportShow = props => {
const translate = useTranslate();
return (
<Show {...props}>
<TabbedShowLayout>
<Tab
label={translate("synapseadmin.reports.tabs.basic", {
smart_count: 1,
})}
icon={<ViewListIcon />}
>
<DateField
source="received_ts"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
sortable={true}
/>
<ReferenceField source="user_id" reference="users">
<TextField source="id" />
</ReferenceField>
<NumberField source="score" />
<TextField source="reason" />
<TextField source="name" />
<TextField
source="canonical_alias"
label="resources.rooms.fields.canonical_alias"
/>
<ReferenceField
source="room_id"
reference="rooms"
link="show"
label="resources.rooms.fields.room_id"
>
<TextField source="id" />
</ReferenceField>
</Tab>
<Tab
label="synapseadmin.reports.tabs.detail"
icon={<PageviewIcon />}
path="detail"
>
{" "}
<DateField
source="event_json.origin_server_ts"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
sortable={true}
/>
<ReferenceField source="sender" reference="users">
<TextField source="id" />
</ReferenceField>
<TextField source="event_id" />
<TextField source="event_json.origin" />
<TextField source="event_json.type" />
<TextField source="event_json.content.msgtype" />
<TextField source="event_json.content.body" />
<TextField source="event_json.content.format" />
<TextField source="event_json.content.formatted_body" />
<TextField source="event_json.content.algorithm" />
<TextField
source="event_json.content.device_id"
label="resources.users.fields.device_id"
/>
</Tab>
</TabbedShowLayout>
</Show>
);
};
export const ReportList = ({ ...props }) => {
return (
<List
{...props}
pagination={<ReportPagination />}
sort={{ field: "received_ts", order: "DESC" }}
bulkActionButtons={false}
>
<Datagrid rowClick="show">
<TextField source="id" sortable={false} />
<DateField
source="received_ts"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
sortable={true}
/>
<TextField sortable={false} source="user_id" />
<TextField sortable={false} source="name" />
<TextField sortable={false} source="score" />
</Datagrid>
</List>
);
};

View file

@ -29,6 +29,7 @@ export default {
"Sind Sie sicher dass Sie den Raum löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden. Alle Nachrichten und Medien, die der Raum beinhaltet werden vom Server gelöscht!",
},
},
reports: { tabs: { basic: "Allgemein", detail: "Details" } },
},
import_users: {
error: {
@ -173,6 +174,30 @@ export default {
unencrypted: "Nicht verschlüsselt",
},
},
reports: {
name: "Ereignisbericht |||| Ereignisberichte",
fields: {
id: "ID",
received_ts: "Meldezeit",
user_id: "Meldender",
name: "Raumname",
score: "Wert",
reason: "Grund",
event_id: "Event-ID",
event_json: {
origin: "Ursprungsserver",
origin_server_ts: "Sendezeit",
type: "Eventtyp",
content: {
msgtype: "Inhaltstyp",
body: "Nachrichteninhalt",
format: "Nachrichtenformat",
formatted_body: "Formatierter Nachrichteninhalt",
algorithm: "Verschlüsselungsalgorithmus",
},
},
},
},
connections: {
name: "Verbindungen",
fields: {

View file

@ -27,6 +27,7 @@ export default {
"Are you sure you want to delete the room? This cannot be undone. All messages and shared media in the room will be deleted from the server!",
},
},
reports: { tabs: { basic: "Basic", detail: "Details" } },
},
import_users: {
error: {
@ -170,6 +171,30 @@ export default {
unencrypted: "Unencrypted",
},
},
reports: {
name: "Reported event |||| Reported events",
fields: {
id: "ID",
received_ts: "report time",
user_id: "announcer",
name: "name of the room",
score: "score",
reason: "reason",
event_id: "event ID",
event_json: {
origin: "origin server",
origin_server_ts: "time of send",
type: "event typ",
content: {
msgtype: "content type",
body: "content",
format: "format",
formatted_body: "formatted content",
algorithm: "algorithm",
},
},
},
},
connections: {
name: "Connections",
fields: {

View file

@ -72,6 +72,15 @@ const resourceMap = {
method: "POST",
}),
},
reports: {
path: "/_synapse/admin/v1/event_reports",
map: er => ({
...er,
id: er.id,
}),
data: "event_reports",
total: json => json.total,
},
devices: {
map: d => ({
...d,