Remove clap dependency
This commit is contained in:
parent
911b26f163
commit
dea5c0b494
3 changed files with 31 additions and 73 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
@ -397,15 +397,6 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ansi_term"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
|
||||||
dependencies = [
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.33"
|
version = "1.0.33"
|
||||||
|
@ -777,21 +768,6 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap"
|
|
||||||
version = "2.33.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
|
||||||
dependencies = [
|
|
||||||
"ansi_term",
|
|
||||||
"atty",
|
|
||||||
"bitflags 1.2.1",
|
|
||||||
"strsim 0.8.0",
|
|
||||||
"textwrap",
|
|
||||||
"unicode-width",
|
|
||||||
"vec_map",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cloudabi"
|
name = "cloudabi"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -813,7 +789,6 @@ version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d325e4f2ffff52ca77d995bb675494d5364aa332499d5f7c7fbb28c25e671f6"
|
checksum = "0d325e4f2ffff52ca77d995bb675494d5364aa332499d5f7c7fbb28c25e671f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
|
||||||
"entities",
|
"entities",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"pest",
|
"pest",
|
||||||
|
@ -980,7 +955,7 @@ dependencies = [
|
||||||
"ident_case",
|
"ident_case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim 0.9.3",
|
"strsim",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3166,12 +3141,6 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
|
@ -3230,15 +3199,6 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "textwrap"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.21"
|
version = "1.0.21"
|
||||||
|
@ -3565,12 +3525,6 @@ version = "1.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
|
checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.1.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -3649,12 +3603,6 @@ version = "0.2.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
|
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vec_map"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
|
|
@ -136,6 +136,22 @@ pub async fn search_by_apub_id(
|
||||||
Url::parse(&query)?
|
Url::parse(&query)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let recursion_counter = &mut 0;
|
||||||
|
let search_result =
|
||||||
|
fetch_remote_object::<SearchAcceptedObjects>(context.client(), &query_url, recursion_counter)
|
||||||
|
.await?;
|
||||||
|
let response = match_search_result(context, search_result, query_url, recursion_counter).await?;
|
||||||
|
|
||||||
|
Ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn match_search_result(
|
||||||
|
context: &LemmyContext,
|
||||||
|
search_result: SearchAcceptedObjects,
|
||||||
|
query_url: Url,
|
||||||
|
recursion_counter: &mut i32,
|
||||||
|
) -> Result<SearchResponse, LemmyError> {
|
||||||
|
let domain = query_url.domain().context("url has no domain")?;
|
||||||
let mut response = SearchResponse {
|
let mut response = SearchResponse {
|
||||||
type_: SearchType::All.to_string(),
|
type_: SearchType::All.to_string(),
|
||||||
comments: vec![],
|
comments: vec![],
|
||||||
|
@ -144,15 +160,7 @@ pub async fn search_by_apub_id(
|
||||||
users: vec![],
|
users: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
let domain = query_url.domain().context("url has no domain")?;
|
match search_result {
|
||||||
let recursion_counter = &mut 0;
|
|
||||||
let response = match fetch_remote_object::<SearchAcceptedObjects>(
|
|
||||||
context.client(),
|
|
||||||
&query_url,
|
|
||||||
recursion_counter,
|
|
||||||
)
|
|
||||||
.await?
|
|
||||||
{
|
|
||||||
SearchAcceptedObjects::Person(p) => {
|
SearchAcceptedObjects::Person(p) => {
|
||||||
let user_uri = p.inner.id(domain)?.context("person has no id")?;
|
let user_uri = p.inner.id(domain)?.context("person has no id")?;
|
||||||
|
|
||||||
|
@ -164,8 +172,6 @@ pub async fn search_by_apub_id(
|
||||||
})
|
})
|
||||||
.await??,
|
.await??,
|
||||||
];
|
];
|
||||||
|
|
||||||
response
|
|
||||||
}
|
}
|
||||||
SearchAcceptedObjects::Group(g) => {
|
SearchAcceptedObjects::Group(g) => {
|
||||||
let community_uri = g.inner.id(domain)?.context("group has no id")?;
|
let community_uri = g.inner.id(domain)?.context("group has no id")?;
|
||||||
|
@ -179,8 +185,6 @@ pub async fn search_by_apub_id(
|
||||||
})
|
})
|
||||||
.await??,
|
.await??,
|
||||||
];
|
];
|
||||||
|
|
||||||
response
|
|
||||||
}
|
}
|
||||||
SearchAcceptedObjects::Page(p) => {
|
SearchAcceptedObjects::Page(p) => {
|
||||||
let post_form = PostForm::from_apub(&p, context, Some(query_url), recursion_counter).await?;
|
let post_form = PostForm::from_apub(&p, context, Some(query_url), recursion_counter).await?;
|
||||||
|
@ -188,8 +192,6 @@ pub async fn search_by_apub_id(
|
||||||
let p = blocking(context.pool(), move |conn| Post::upsert(conn, &post_form)).await??;
|
let p = blocking(context.pool(), move |conn| Post::upsert(conn, &post_form)).await??;
|
||||||
response.posts =
|
response.posts =
|
||||||
vec![blocking(context.pool(), move |conn| PostView::read(conn, p.id, None)).await??];
|
vec![blocking(context.pool(), move |conn| PostView::read(conn, p.id, None)).await??];
|
||||||
|
|
||||||
response
|
|
||||||
}
|
}
|
||||||
SearchAcceptedObjects::Comment(c) => {
|
SearchAcceptedObjects::Comment(c) => {
|
||||||
let comment_form =
|
let comment_form =
|
||||||
|
@ -205,8 +207,6 @@ pub async fn search_by_apub_id(
|
||||||
})
|
})
|
||||||
.await??,
|
.await??,
|
||||||
];
|
];
|
||||||
|
|
||||||
response
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -391,7 +391,17 @@ async fn fetch_remote_community(
|
||||||
.await??;
|
.await??;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch outbox (maybe make this conditional)
|
// maybe make this conditional
|
||||||
|
fetch_community_outbox(context, &community, recursion_counter).await?;
|
||||||
|
|
||||||
|
Ok(community)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_community_outbox(
|
||||||
|
context: &LemmyContext,
|
||||||
|
community: &Community,
|
||||||
|
recursion_counter: &mut i32,
|
||||||
|
) -> Result<(), LemmyError> {
|
||||||
let outbox = fetch_remote_object::<OrderedCollection>(
|
let outbox = fetch_remote_object::<OrderedCollection>(
|
||||||
context.client(),
|
context.client(),
|
||||||
&community.get_outbox_url()?,
|
&community.get_outbox_url()?,
|
||||||
|
@ -425,7 +435,7 @@ async fn fetch_remote_community(
|
||||||
// TODO: we need to send a websocket update here
|
// TODO: we need to send a websocket update here
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(community)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a post by its apub ID. If it exists locally, it is returned directly. Otherwise it is
|
/// Gets a post by its apub ID. If it exists locally, it is returned directly. Otherwise it is
|
||||||
|
|
|
@ -19,7 +19,7 @@ percent-encoding = "2.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"]}
|
serde_json = { version = "1.0", features = ["preserve_order"]}
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
comrak = "0.8"
|
comrak = { version = "0.8", default-features = false }
|
||||||
lazy_static = "1.3"
|
lazy_static = "1.3"
|
||||||
openssl = "0.10"
|
openssl = "0.10"
|
||||||
url = { version = "2.1", features = ["serde"] }
|
url = { version = "2.1", features = ["serde"] }
|
||||||
|
|
Loading…
Reference in a new issue