If unconfigured, let get_all_self_addrs() return vec![], not vec![""];

This commit is contained in:
Hocuri
2022-04-19 17:17:14 +02:00
committed by holger krekel
parent 5ee2f3696d
commit bc809986e7
3 changed files with 3 additions and 4 deletions

View File

@@ -376,7 +376,7 @@ impl Context {
pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>> {
let mut ret = Vec::new();
ret.push(self.get_primary_self_addr().await.unwrap_or_default());
ret.extend(self.get_primary_self_addr().await.into_iter());
ret.extend(self.get_secondary_self_addrs().await?.into_iter());
Ok(ret)

View File

@@ -1509,6 +1509,8 @@ mod tests {
async fn test_get_contacts() -> Result<()> {
let context = TestContext::new().await;
assert!(context.get_all_self_addrs().await?.is_empty());
// Bob is not in the contacts yet.
let contacts = Contact::get_all(&context.ctx, 0, Some("bob")).await?;
assert_eq!(contacts.len(), 0);

View File

@@ -844,9 +844,6 @@ async fn prune_tombstones(sql: &Sql) -> Result<()> {
/// Use this together with [`rusqlite::ParamsFromIter`] to use dynamically generated
/// parameter lists.
pub fn repeat_vars(count: usize) -> Result<String> {
if count == 0 {
bail!("Must have at least one repeat variable");
}
let mut s = "?,".repeat(count);
s.pop(); // Remove trailing comma
Ok(s)