appservice: Rename verify_hs_token to hs_token_matches

master
Johannes Becker 2021-05-10 09:11:15 +02:00
parent 325531d13f
commit 14bc4eb7e0
3 changed files with 5 additions and 5 deletions

View File

@ -65,7 +65,7 @@ async fn push_transactions(
request: IncomingRequest<api::event::push_events::v1::IncomingRequest>,
appservice: Data<Appservice>,
) -> Result<HttpResponse, Error> {
if !appservice.verify_hs_token(request.access_token) {
if !appservice.hs_token_matches(request.access_token) {
return Ok(HttpResponse::Unauthorized().finish());
}
@ -84,7 +84,7 @@ async fn query_user_id(
request: IncomingRequest<api::query::query_user_id::v1::IncomingRequest>,
appservice: Data<Appservice>,
) -> Result<HttpResponse, Error> {
if !appservice.verify_hs_token(request.access_token) {
if !appservice.hs_token_matches(request.access_token) {
return Ok(HttpResponse::Unauthorized().finish());
}
@ -97,7 +97,7 @@ async fn query_room_alias(
request: IncomingRequest<api::query::query_room_alias::v1::IncomingRequest>,
appservice: Data<Appservice>,
) -> Result<HttpResponse, Error> {
if !appservice.verify_hs_token(request.access_token) {
if !appservice.hs_token_matches(request.access_token) {
return Ok(HttpResponse::Unauthorized().finish());
}

View File

@ -272,7 +272,7 @@ impl Appservice {
/// Compare the given `hs_token` against `registration.hs_token`
///
/// Returns `true` if the tokens match, `false` otherwise.
pub fn verify_hs_token(&self, hs_token: impl AsRef<str>) -> bool {
pub fn hs_token_matches(&self, hs_token: impl AsRef<str>) -> bool {
self.registration.hs_token == hs_token.as_ref()
}

View File

@ -119,7 +119,7 @@ async fn test_verify_hs_token() -> Result<()> {
let registration = appservice.registration();
assert!(appservice.verify_hs_token(&registration.hs_token));
assert!(appservice.hs_token_matches(&registration.hs_token));
Ok(())
}