#217 overview of suspicious profiles
This commit is contained in:
parent
fb689e2f6c
commit
94f4f4f961
|
@ -0,0 +1,5 @@
|
|||
-- Up
|
||||
|
||||
ALTER TABLE users ADD COLUMN suspiciousChecked TINYINT NOT NULL DEFAULT 0;
|
||||
|
||||
-- Down
|
|
@ -84,6 +84,36 @@
|
|||
|
||||
<ChartSet name="users" :data="stats.users.chart" init="cumulative"/>
|
||||
|
||||
<section v-if="$isGranted('users') && suspiciousUsers.length > 0">
|
||||
<h3>
|
||||
<Icon v="siren-on"/>
|
||||
Suspicious accounts
|
||||
</h3>
|
||||
<Table :data="suspiciousUsers" columns="2">
|
||||
<template v-slot:row="s"><template v-if="s">
|
||||
<td>
|
||||
<LocaleLink :link="`/@${s.el.username}`" :locale="s.el.locale">
|
||||
{{s.el.username}}
|
||||
<span class="badge bg-light text-dark">{{s.el.locale}}</span>
|
||||
</LocaleLink>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="badge bg-light text-success border border-success float-end"
|
||||
@click.prevent="checkedSuspicious(s.el.id)"
|
||||
>
|
||||
<Icon v="thumbs-up"/>
|
||||
I checked the profile, it's OK.
|
||||
</a>
|
||||
</td>
|
||||
</template></template>
|
||||
|
||||
<template v-slot:empty>
|
||||
<Icon v="search"/>
|
||||
<T>nouns.empty</T>
|
||||
</template>
|
||||
</Table>
|
||||
</section>
|
||||
|
||||
<section v-for="(locale, k) in stats.locales" :key="k">
|
||||
<details class="border mb-3" open>
|
||||
<summary class="bg-light p-3">
|
||||
|
@ -150,13 +180,18 @@
|
|||
},
|
||||
async asyncData({ app, store }) {
|
||||
let stats = { users: {}};
|
||||
|
||||
try {
|
||||
stats = await app.$axios.$get(`/admin/stats`);
|
||||
} catch {}
|
||||
|
||||
let suspiciousUsers = [];
|
||||
try {
|
||||
suspiciousUsers = await app.$axios.$get(`/admin/suspicious`);
|
||||
} catch {}
|
||||
|
||||
return {
|
||||
stats,
|
||||
suspiciousUsers,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
@ -165,6 +200,11 @@
|
|||
this.users = await this.$axios.$get(`/admin/users`);
|
||||
}
|
||||
},
|
||||
async checkedSuspicious(id) {
|
||||
await this.$confirm('Are you sure you want to mark this profile as not suspicious?', 'success');
|
||||
await this.$post(`/admin/suspicious/checked/${id}`);
|
||||
this.suspiciousUsers = this.suspiciousUsers.filter(u => u.id !== id);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
visibleUsers() {
|
||||
|
|
|
@ -133,4 +133,38 @@ router.post('/admin/ban/:username', handleErrorAsync(async (req, res) => {
|
|||
return res.json(true);
|
||||
}));
|
||||
|
||||
router.get('/admin/suspicious', handleErrorAsync(async (req, res) => {
|
||||
if (!req.isGranted('users')) {
|
||||
return res.status(401).json({error: 'Unauthorised'});
|
||||
}
|
||||
|
||||
return res.json(await req.db.all(SQL`
|
||||
SELECT users.id, users.username, profiles.locale FROM profiles
|
||||
LEFT JOIN users ON profiles.userId = users.id
|
||||
WHERE users.suspiciousChecked != 1
|
||||
AND users.bannedReason IS NULL
|
||||
AND (
|
||||
lower(customFlags) LIKE '%super%'
|
||||
OR lower(description) LIKE '%super%'
|
||||
OR lower(customFlags) LIKE '%phobe%'
|
||||
OR lower(description) LIKE '%phobe%'
|
||||
)
|
||||
ORDER BY users.id DESC
|
||||
`));
|
||||
}));
|
||||
|
||||
router.post('/admin/suspicious/checked/:id', handleErrorAsync(async (req, res) => {
|
||||
if (!req.isGranted('users')) {
|
||||
return res.status(401).json({error: 'Unauthorised'});
|
||||
}
|
||||
|
||||
await req.db.get(SQL`
|
||||
UPDATE users
|
||||
SET suspiciousChecked = 1
|
||||
WHERE id=${req.params.id}
|
||||
`);
|
||||
|
||||
return res.json(true);
|
||||
}));
|
||||
|
||||
export default router;
|
||||
|
|
Reference in New Issue