-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
Instance blocks with mod log entry and expiration (fixes #2506) #5214
base: main
Are you sure you want to change the base?
Conversation
6262929
to
2a1d3c9
Compare
156b352
to
f9bb606
Compare
.route("/list", get().to(list_taglines)), | ||
) | ||
.route("block_instance", post().to(admin_block_instance)) | ||
.route("allow_instance", post().to(admin_allow_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.
I removed useless the web::
prefix all over this file, only real change is here.
fc69e7e
to
f0838ed
Compare
2768e73
to
ebcde20
Compare
Updated |
pub struct BlockInstanceResponse { | ||
pub blocked: bool, | ||
pub struct AdminAllowInstanceParams { | ||
pub instance: 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.
Had to change these from instance_id to domain, otherwise it would be very complicated to initialize the tests. It would also be possible to allow both instance id or domain in the same field, but ts-rs would probably not understand that.
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.
That's fine, especially since you might not be connected to the instance yet anyway, so it might not have an id, and you need to read or create it in the API route.
6ed361d
to
7d0f136
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.
Thx for the re-org of mod tables also, that'll be useful for my work on #2444
pub struct BlockInstanceResponse { | ||
pub blocked: bool, | ||
pub struct AdminAllowInstanceParams { | ||
pub instance: 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.
That's fine, especially since you might not be connected to the instance yet anyway, so it might not have an id, and you need to read or create it in the API route.
blocked bool NOT NULL, | ||
reason text, | ||
expires timestamptz, | ||
published timestamptz NOT NULL DEFAULT now() |
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.
All the mod tables use a when_
column instead of published. We should pry keep that uniform for now.
admin_person_id int NOT NULL REFERENCES person (id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
allowed bool NOT NULL, | ||
reason text, | ||
published timestamptz NOT NULL DEFAULT now() |
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.
Same
var block_instance_params: AdminBlockInstanceParams = { | ||
instance: "lemmy-alpha", | ||
block: true, | ||
reason: undefined, |
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.
You should be able to just leave off reason
, esp since it should be optional.
const params: AdminAllowInstanceParams = { | ||
instance, | ||
allow: true, | ||
reason: undefined, |
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.
Same
|
||
diesel::delete( | ||
federation_blocklist::table.filter(federation_blocklist::expires.lt(now().nullable())), | ||
) | ||
.execute(&mut conn) | ||
.await | ||
.inspect_err(|e| error!("Failed to remove federation_blocklist expired rows: {e}")) | ||
.ok(); |
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.
Probably a good idea to move this to its own function, since the other two are ban expires, but this is an instance block expires.
PUT /api/v3/site
anymore, instead there are new endpointsPOST /api/v3/admin/block_instance
andPOST /api/v3/admin/allow_instance
The main implementation is done, will wait for initial code review before making changes to js client and api tests.