-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added reason column to federation_blocklist #3168
Conversation
3617c8b
to
2a4324e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat torn, because nearly every reason
we have is in the mod_
tables... the idea being that each action can leave a trace in the modlog. Without modlog tables, those changes in reason, as well as blocking / unblocking instances could get lost.
But I think for this one, its fine, since it'd also be nice to show the reason on the instances page, without having to do any weird sql joins grabbing the most recent reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would ur opinion be on having corresponding mod tables for changes to allow/blocklists, with the source of truth for current values still being the federation_blocklist
/federation_allowlist
tables? effectively the mod tables would be audit logs rather than something the application itself would refer to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd def be good with that. My issue is that I'd rather not duplicate any data, and make sure that the reason is either in one table or the other, but not both. reason
typically goes for modlog entries, because things like bans and removes don't necessarily represent a permanent state of affairs. That probably should also apply here, where you might block, then unblock instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've had a quick investigation of this and while it's definitely possible, the changeset did start ballooning because of the joins (to the latest entry of) the new table. i suspect it might be better implemented as a separate commit, but at the end of the day it's up to you whether you'd rather it get done completely and correctly at this point, or whether it's ok to get this in without the log table and i can raise an issue to add it as a separate bit of work?
ea3ecf2
to
6881927
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes its a bit circular, but once @Nutomic approves this, I'll publish a new lemmy-js-client version with these API additions, and ping you.
Then you'll add that version to the api_tests/package.json
, and the tests should pass.
Looks good to me. |
6881927
to
81939f4
Compare
i've realised that if this was done without using an admin_ table now, it'd potentially be a pain to add one later (since the table would require an admin's id and therefore migrations out of the federation_blocklist table's reason column would be impossible) just added a commit attempting to solve this using a new
|
0cec99a
to
b9f179f
Compare
b9f179f
to
99c8606
Compare
@@ -0,0 +1,10 @@ | |||
-- add the admin_block_instance table | |||
|
|||
create table admin_block_instance ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, adding this as a mod table is better.
@@ -0,0 +1 @@ | |||
-- This file should undo anything in `up.sql` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the table delete.
#[cfg_attr(feature = "full", derive(TS))] | ||
#[cfg_attr(feature = "full", ts(export))] | ||
pub struct BlockedInstance { | ||
pub id: InstanceId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird... what's this about. It should only be a modlog table now.
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
#[cfg_attr(feature = "full", derive(TS))] | ||
#[cfg_attr(feature = "full", ts(export))] | ||
/// A list of federated instances. | ||
pub struct FederatedInstances { | ||
pub linked: Vec<Instance>, | ||
pub allowed: Vec<Instance>, | ||
pub blocked: Vec<Instance>, | ||
pub blocked: Vec<BlockedInstance>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No just return the Instance. The block and reasons should be included in the modlog only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to support the UI being able to show reasons for each blocked domain
let mut unblocked_instances = existing_blocked_instances | ||
.keys() | ||
.cloned() | ||
.collect::<HashSet<String>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really weird joining, none of it is necessary. You only need to add the AdminBlockInstance view to the moderation tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is necessary unless i'm misunderstanding.
the updates to the blocklist come as a complete set of blocked domains + reasons.
we've then got existing blocked domains + reasons and need to figure out what to put in the mod table, but there can be:
- newly added domains;
- existing domains with new reasons;
- existing unchanged domains;
- removed domains.
presumably we want to add entries for any newly added domains or existing domains with new reasons with a blocked
flag since they represent admin actions. we also want to add entries for removed domains with the blocked
flag false to represent the admin removing that domain.
i think the removed part is definitely necessary, the part figuring out created/edited could be removed, but then if you've got a list of 100 blocked domains and the admin edits the reason for one of them, or just removes one of them you'd be putting 100 unnecessary items in the admin log
Closing because its abandoned. |
This allows blocked instances to (optionally) have a reason set.
Addresses issue: #1947
Linked UI MR: LemmyNet/lemmy-ui#1367
I've just picked this issue up (by searching for 'good first issue's) as a way of dipping my feet into this project and I've only really tinkered with rust in toy projects before so please let me know if there's any problems.