mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-28 23:31:21 +00:00
fix setup
This commit is contained in:
parent
1324963fb9
commit
1001e3f67a
6 changed files with 51 additions and 41 deletions
|
@ -28,7 +28,7 @@
|
||||||
"eslint": "^9.14.0",
|
"eslint": "^9.14.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
"lemmy-js-client": "0.20.0-instance-blocks.2",
|
"lemmy-js-client": "0.20.0-instance-blocks.5",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"ts-jest": "^29.1.0",
|
"ts-jest": "^29.1.0",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
|
|
|
@ -30,8 +30,8 @@ importers:
|
||||||
specifier: ^29.5.0
|
specifier: ^29.5.0
|
||||||
version: 29.7.0(@types/node@22.9.0)
|
version: 29.7.0(@types/node@22.9.0)
|
||||||
lemmy-js-client:
|
lemmy-js-client:
|
||||||
specifier: 0.20.0-instance-blocks.2
|
specifier: 0.20.0-instance-blocks.5
|
||||||
version: 0.20.0-instance-blocks.2
|
version: 0.20.0-instance-blocks.5
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.2.5
|
specifier: ^3.2.5
|
||||||
version: 3.3.3
|
version: 3.3.3
|
||||||
|
@ -1167,8 +1167,8 @@ packages:
|
||||||
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
|
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
lemmy-js-client@0.20.0-instance-blocks.2:
|
lemmy-js-client@0.20.0-instance-blocks.5:
|
||||||
resolution: {integrity: sha512-R7+O/jGSvl7URWy/Gp4WRdH9EjkDmo5GRbQwJMOSM2HmFi9PIzcMynYbrNC869pbnI8S/XsitVfv9sLTuthpDg==}
|
resolution: {integrity: sha512-wDuRFzg32lbbJr4cNmd+cbzjgw+okw2/d5AujYjAm4gv0OEFfsYhP3QQ2WscwUR5HJTdzsR7IIyiBnvmaEUzUw==}
|
||||||
|
|
||||||
leven@3.1.0:
|
leven@3.1.0:
|
||||||
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
|
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
|
||||||
|
@ -3077,7 +3077,7 @@ snapshots:
|
||||||
|
|
||||||
kleur@3.0.3: {}
|
kleur@3.0.3: {}
|
||||||
|
|
||||||
lemmy-js-client@0.20.0-instance-blocks.2: {}
|
lemmy-js-client@0.20.0-instance-blocks.5: {}
|
||||||
|
|
||||||
leven@3.1.0: {}
|
leven@3.1.0: {}
|
||||||
|
|
||||||
|
|
|
@ -169,36 +169,30 @@ export async function setupLogins() {
|
||||||
rate_limit_comment: 999,
|
rate_limit_comment: 999,
|
||||||
rate_limit_search: 999,
|
rate_limit_search: 999,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the blocks and auths for each
|
|
||||||
editSiteForm.allowed_instances = [
|
|
||||||
"lemmy-beta",
|
|
||||||
"lemmy-gamma",
|
|
||||||
"lemmy-delta",
|
|
||||||
"lemmy-epsilon",
|
|
||||||
];
|
|
||||||
await alpha.editSite(editSiteForm);
|
await alpha.editSite(editSiteForm);
|
||||||
const params: AdminAllowInstanceParams = {
|
|
||||||
instance_id: 0,
|
|
||||||
allow: true,
|
|
||||||
reason: undefined
|
|
||||||
};
|
|
||||||
await alpha.adminAllowInstance(params);
|
|
||||||
|
|
||||||
editSiteForm.allowed_instances = betaAllowedInstances;
|
|
||||||
await beta.editSite(editSiteForm);
|
await beta.editSite(editSiteForm);
|
||||||
|
|
||||||
editSiteForm.allowed_instances = [
|
|
||||||
"lemmy-alpha",
|
|
||||||
"lemmy-beta",
|
|
||||||
"lemmy-delta",
|
|
||||||
"lemmy-epsilon",
|
|
||||||
];
|
|
||||||
await gamma.editSite(editSiteForm);
|
await gamma.editSite(editSiteForm);
|
||||||
|
await delta.editSite(editSiteForm);
|
||||||
|
await epsilon.editSite(editSiteForm);
|
||||||
|
|
||||||
|
// Set the blocksfor each
|
||||||
|
await allowInstance(alpha, "lemmy-beta");
|
||||||
|
await allowInstance(alpha, "lemmy-gamma");
|
||||||
|
await allowInstance(alpha, "lemmy-delta");
|
||||||
|
await allowInstance(alpha, "lemmy-epsilon");
|
||||||
|
|
||||||
|
await allowInstance(beta, "lemmy-alpha");
|
||||||
|
await allowInstance(beta, "lemmy-gamma");
|
||||||
|
await allowInstance(beta, "lemmy-delta");
|
||||||
|
await allowInstance(beta, "lemmy-epsilon");
|
||||||
|
|
||||||
|
await allowInstance(gamma, "lemmy-alpha");
|
||||||
|
await allowInstance(gamma, "lemmy-beta");
|
||||||
|
await allowInstance(gamma, "lemmy-delta");
|
||||||
|
await allowInstance(gamma, "lemmy-epsilon");
|
||||||
|
|
||||||
// Setup delta allowed instance
|
// Setup delta allowed instance
|
||||||
editSiteForm.allowed_instances = ["lemmy-beta"];
|
await allowInstance(delta, "lemmy-beta");
|
||||||
await delta.editSite(editSiteForm);
|
|
||||||
|
|
||||||
// Create the main alpha/beta communities
|
// Create the main alpha/beta communities
|
||||||
// Ignore thrown errors of duplicates
|
// Ignore thrown errors of duplicates
|
||||||
|
@ -215,6 +209,16 @@ export async function setupLogins() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function allowInstance(
|
||||||
|
api: LemmyHttp,instance: string) {
|
||||||
|
const params: AdminAllowInstanceParams = {
|
||||||
|
instance,
|
||||||
|
allow: true,
|
||||||
|
reason: undefined
|
||||||
|
};
|
||||||
|
await api.adminAllowInstance(params);
|
||||||
|
}
|
||||||
|
|
||||||
export async function createPost(
|
export async function createPost(
|
||||||
api: LemmyHttp,
|
api: LemmyHttp,
|
||||||
community_id: number,
|
community_id: number,
|
||||||
|
|
|
@ -28,18 +28,21 @@ pub async fn admin_allow_instance(
|
||||||
Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?;
|
Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let instance_id = Instance::read_or_create(&mut context.pool(), data.instance.clone())
|
||||||
|
.await?
|
||||||
|
.id;
|
||||||
let form = FederationAllowListForm {
|
let form = FederationAllowListForm {
|
||||||
instance_id: data.instance_id,
|
instance_id: instance_id,
|
||||||
updated: None,
|
updated: None,
|
||||||
};
|
};
|
||||||
if data.allow {
|
if data.allow {
|
||||||
FederationAllowList::allow(&mut context.pool(), &form).await?;
|
FederationAllowList::allow(&mut context.pool(), &form).await?;
|
||||||
} else {
|
} else {
|
||||||
FederationAllowList::unallow(&mut context.pool(), data.instance_id).await?;
|
FederationAllowList::unallow(&mut context.pool(), instance_id).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mod_log_form = AdminAllowInstanceForm {
|
let mod_log_form = AdminAllowInstanceForm {
|
||||||
instance_id: data.instance_id,
|
instance_id,
|
||||||
admin_person_id: local_user_view.person.id,
|
admin_person_id: local_user_view.person.id,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
allowed: data.allow,
|
allowed: data.allow,
|
||||||
|
|
|
@ -28,8 +28,11 @@ pub async fn admin_block_instance(
|
||||||
Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?;
|
Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let instance_id = Instance::read_or_create(&mut context.pool(), data.instance.clone())
|
||||||
|
.await?
|
||||||
|
.id;
|
||||||
let form = FederationBlockListForm {
|
let form = FederationBlockListForm {
|
||||||
instance_id: data.instance_id,
|
instance_id,
|
||||||
expires: data.expires,
|
expires: data.expires,
|
||||||
updated: None,
|
updated: None,
|
||||||
};
|
};
|
||||||
|
@ -37,11 +40,11 @@ pub async fn admin_block_instance(
|
||||||
if data.block {
|
if data.block {
|
||||||
FederationBlockList::block(&mut context.pool(), &form).await?;
|
FederationBlockList::block(&mut context.pool(), &form).await?;
|
||||||
} else {
|
} else {
|
||||||
FederationBlockList::unblock(&mut context.pool(), data.instance_id).await?;
|
FederationBlockList::unblock(&mut context.pool(), instance_id).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mod_log_form = AdminBlockInstanceForm {
|
let mod_log_form = AdminBlockInstanceForm {
|
||||||
instance_id: data.instance_id,
|
instance_id: instance_id,
|
||||||
admin_person_id: local_user_view.person.id,
|
admin_person_id: local_user_view.person.id,
|
||||||
blocked: data.block,
|
blocked: data.block,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
|
|
|
@ -647,11 +647,11 @@ pub struct UserBlockInstanceParams {
|
||||||
pub block: bool,
|
pub block: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "full", derive(TS))]
|
#[cfg_attr(feature = "full", derive(TS))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
pub struct AdminBlockInstanceParams {
|
pub struct AdminBlockInstanceParams {
|
||||||
pub instance_id: InstanceId,
|
pub instance: String,
|
||||||
pub block: bool,
|
pub block: bool,
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
|
@ -659,11 +659,11 @@ pub struct AdminBlockInstanceParams {
|
||||||
pub expires: Option<DateTime<Utc>>,
|
pub expires: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "full", derive(TS))]
|
#[cfg_attr(feature = "full", derive(TS))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
pub struct AdminAllowInstanceParams {
|
pub struct AdminAllowInstanceParams {
|
||||||
pub instance_id: InstanceId,
|
pub instance: String,
|
||||||
pub allow: bool,
|
pub allow: bool,
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
pub reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
|
|
Loading…
Reference in a new issue