Merge pull request #2053 from RoboSats/anually-verify-ratings

Manually verify ratings
This commit is contained in:
KoalaSat
2025-07-09 15:00:39 +00:00
committed by GitHub
19 changed files with 126 additions and 7 deletions

View File

@ -72,7 +72,6 @@ import { systemClient } from '../../services/System';
import type Coordinator from '../../models/Coordinator.model';
import { type Badges } from '../../models/Coordinator.model';
import { type UseFederationStoreType, FederationContext } from '../../contexts/FederationContext';
import { verifyCoordinatorToken } from '../../utils/nostr';
interface Props {
open: boolean;
@ -367,9 +366,8 @@ const CoordinatorDialog = ({ open = false, onClose, shortAlias }: Props): React.
federation.roboPool.subscribeRatings(
{
onevent: (event) => {
const verfied = verifyCoordinatorToken(event);
const coordinatorPubKey = event.tags.find((t) => t[0] === 'p')?.[1];
if (verfied && coordinatorPubKey === coordinator.nostrHexPubkey) {
if (coordinatorPubKey === coordinator.nostrHexPubkey) {
const eventRating = event.tags.find((t) => t[0] === 'rating')?.[1];
if (eventRating) {
setRating((prev) => {

View File

@ -1,6 +1,15 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { Link, LinkOff } from '@mui/icons-material';
import { Box, Checkbox, CircularProgress, Grid, Rating, Typography, useTheme } from '@mui/material';
import {
Box,
Button,
Checkbox,
CircularProgress,
Grid,
Rating,
Typography,
useTheme,
} from '@mui/material';
import { DataGrid, type GridColDef, type GridValidRowModel } from '@mui/x-data-grid';
import { useTranslation } from 'react-i18next';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
@ -33,6 +42,8 @@ const FederationTable = ({
}, {}),
);
const [useDefaultPageSize, setUseDefaultPageSize] = useState(true);
const [verifyRatings, setVerifyRatings] = useState(false);
const [verifcationText, setVerificationText] = useState<string>();
// all sizes in 'em'
const fontSize = theme.typography.fontSize;
@ -49,6 +60,13 @@ const FederationTable = ({
loadRatings();
}, []);
useEffect(() => {
if (verifyRatings) {
loadRatings();
setVerificationText(t('Reloading. Invalid ratings will be filtered.'));
}
}, [verifyRatings]);
useEffect(() => {
if (useDefaultPageSize) {
setPageSize(defaultPageSize);
@ -56,11 +74,17 @@ const FederationTable = ({
}, [federationUpdatedAt]);
const loadRatings: () => void = () => {
setRatings(
federation.getCoordinators().reduce((acc, coord) => {
if (coord.nostrHexPubkey) acc[coord.nostrHexPubkey] = {};
return acc;
}, {}),
);
federation.roboPool.subscribeRatings({
onevent: (event) => {
const verfied = verifyCoordinatorToken(event);
const coordinatorPubKey = event.tags.find((t) => t[0] === 'p')?.[1];
if (verfied && coordinatorPubKey) {
const verified = verifyRatings ? verifyCoordinatorToken(event) : true;
if (verified && coordinatorPubKey) {
const rating = event.tags.find((t) => t[0] === 'rating')?.[1];
if (rating) {
setRatings((prev) => {
@ -70,7 +94,9 @@ const FederationTable = ({
}
}
},
oneose: () => {},
oneose: () => {
if (verifyRatings) setVerificationText(t('Invalid ratings have been filtered.'));
},
});
};
@ -333,6 +359,33 @@ const FederationTable = ({
}}
hideFooter={true}
/>
<Grid item>
{!verifcationText && (
<Button
sx={{ maxHeight: 38, mt: '1em' }}
disabled={false}
onClick={() => setVerifyRatings(true)}
variant='contained'
color='secondary'
size='small'
type='submit'
>
{t('Verify ratings')}
</Button>
)}
<Typography
variant='body2'
color={verifcationText ? 'success.main' : 'warning.main'}
sx={{ mt: 2, fontWeight: 'bold' }}
>
{verifcationText
? verifcationText
: t(
'Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.',
)}
</Typography>
</Grid>
</Box>
);
};

View File

@ -361,9 +361,13 @@
"Warning": "Avís",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Habilitat",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No s'han trobat coordinadors.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Pujar",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "El client RoboSats és servit pel teu propi node, gaudeixes de la major seguretat i privacitat.",
"You are self-hosting RoboSats": "Estàs hostejant RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "El cliente RoboSats es servido por tu propio nodo, gozas de la mayor seguridad y privacidad.",
"You are self-hosting RoboSats": "Estás alojando RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats webgunea zure nodotik zerbitzatzen da beraz segurtasun eta pribatutasun sendoena eskaintzen dizu.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "Le client RoboSats est servi à partir de votre propre nœud, ce qui vous garantit une sécurité et une confidentialité optimales.",
"You are self-hosting RoboSats": "Vous auto-hébergez RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "Il client RoboSats è servito dal proprio nodo, garantendo la massima sicurezza e privacy.",
"You are self-hosting RoboSats": "Stai ospitando RoboSats in autonomia",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSatsクライアントは、あなた自身のードから提供され、最高のセキュリティとプライバシーが保証されます。",
"You are self-hosting RoboSats": "RoboSatsを自己ホスティングしています",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "Клиент RoboSats обслуживается с вашего собственного нода, что обеспечивает максимальную безопасность и конфиденциальность.",
"You are self-hosting RoboSats": "Вы самостоятельно размещаете RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "You are self-hosting RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "Mteja wa RoboSats unatolewa kutoka kwenye node yako mwenyewe ikikupa usalama na faragha imara kabisa.",
"You are self-hosting RoboSats": "Unaendesha RoboSats yako mwenyewe",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats client is served from your own node granting you the strongest security and privacy.",
"You are self-hosting RoboSats": "คูณกำลัง host RoboSats เอง",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats 客户端已由你自己的节点提供服务,为你提供最强的安全性和隐私性。",
"You are self-hosting RoboSats": "你在自托管 RoboSats",

View File

@ -361,9 +361,13 @@
"Warning": "Warning",
"#39": "Phrases in components/FederationTable/index.tsx",
"Enabled": "Enabled",
"Invalid ratings have been filtered.": "Invalid ratings have been filtered.",
"No coordinators found.": "No coordinators found.",
"Rating": "Rating",
"Reloading. Invalid ratings will be filtered.": "Reloading. Invalid ratings will be filtered.",
"Up": "Up",
"Verify ratings": "Verify ratings",
"Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.": "Verifying all ratings might take some time; this window may freeze for a few seconds while the cryptographic certification is in progress.",
"#40": "Phrases in components/HostAlert/SelfhostedAlert.tsx",
"RoboSats client is served from your own node granting you the strongest security and privacy.": "RoboSats客戶端已由你自己的節點提供服務為你提供最強的安全性和隱私性。",
"You are self-hosting RoboSats": "你在自託管 RoboSats",