Skip to content

Commit

Permalink
Use npub if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed May 30, 2024
1 parent 1226839 commit 20cb057
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/actors/slack_writer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// This module contains the SlackWriter actor, which is responsible for knowing
/// how to write to slack and can fetch info from Nostr to create its messages
use super::messages::SupervisorMessage;
use crate::actors::messages::SlackWriterMessage;
use crate::domain_objects::{ReportRequest, ReportTarget};
Expand Down Expand Up @@ -48,6 +50,7 @@ where
state: &mut Self::State,
) -> Result<(), ActorProcessingErr> {
match message {
// TODO: We should break this dependency on ReportRequest
Self::Msg::Write(report_request) => {
if let ReportTarget::Event(_) = report_request.target() {
info!("Ignoring event report request for slack writer");
Expand Down
5 changes: 4 additions & 1 deletion src/adapters/http_server/slack_interactions_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ async fn try_njump(
Ok(maybe_reporter_nip05
.as_ref()
.map(|nip05| format!("https://njump.me/{}", nip05))
.unwrap_or(format!("`{}`", pubkey)))
.unwrap_or(format!(
"`{}`",
pubkey.to_bech32().unwrap_or(pubkey.to_string())
)))
}

fn parse_slack_action(
Expand Down
8 changes: 7 additions & 1 deletion src/adapters/slack_client_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use anyhow::Result;
use hyper_rustls::HttpsConnector;
use hyper_util::client::legacy::connect::HttpConnector;
use nostr_sdk::prelude::PublicKey;
use nostr_sdk::ToBech32;
use ractor::{call_t, ActorRef};
use slack_morphism::prelude::*;
use std::env;
Expand Down Expand Up @@ -41,14 +42,19 @@ impl SlackClientAdapter {
Ok(())
}

// This fn is currently duplicated and lives too in the http client adapter.
// It should be moved to a shared place at some point
async fn try_njump(&self, pubkey: PublicKey) -> Result<String> {
let maybe_reporter_nip05 =
call_t!(self.nostr_actor, SupervisorMessage::GetNip05, 100, pubkey)?;

Ok(maybe_reporter_nip05
.as_ref()
.map(|nip05| format!("https://njump.me/{}", nip05))
.unwrap_or(format!("`{}`", pubkey)))
.unwrap_or(format!(
"`{}`",
pubkey.to_bech32().unwrap_or(pubkey.to_string())
)))
}
}

Expand Down

0 comments on commit 20cb057

Please sign in to comment.