Skip to content

Commit 1523cb7

Browse files
committed
Fix Zulip username formatting in lookup github
1 parent 33c0966 commit 1523cb7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/zulip.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,18 @@ async fn lookup_github_username(ctx: &Context, zulip_username: &str) -> anyhow::
543543
}
544544
};
545545

546-
Ok(format!("{zulip_username}'s GitHub profile is [{github_username}](https://github.com/{github_username})."))
546+
Ok(format!(
547+
"{}'s GitHub profile is [{github_username}](https://github.com/{github_username}).",
548+
render_zulip_username(zulip_user.user_id)
549+
))
550+
}
551+
552+
fn render_zulip_username(zulip_id: u64) -> String {
553+
// Rendering the username directly was running into some encoding issues, so we use
554+
// the special `|<user-id>` syntax instead.
555+
// @**|<zulip-id>** is Zulip syntax that will render as the username (and a link) of the user
556+
// with the given Zulip ID.
557+
format!("@**|{zulip_id}**")
547558
}
548559

549560
/// Tries to find a Zulip username from a GitHub username.
@@ -599,10 +610,9 @@ async fn lookup_zulip_username(ctx: &Context, gh_username: &str) -> anyhow::Resu
599610
}
600611
},
601612
};
602-
// @**|<zulip-id>** is Zulip syntax that will render as the username (and a link) of the user
603-
// with the given Zulip ID.
604613
Ok(format!(
605-
"The GitHub user `{gh_username}` has the following Zulip account: @**|{zulip_id}**"
614+
"The GitHub user `{gh_username}` has the following Zulip account: {}",
615+
render_zulip_username(zulip_id)
606616
))
607617
}
608618

0 commit comments

Comments
 (0)