pushing changes

This commit is contained in:
Jack Chakany 2024-09-23 11:44:49 -04:00
parent dbf50ec455
commit 8c80d252d0
4 changed files with 62 additions and 1 deletions

View file

@ -25,6 +25,6 @@ puffin_http = { version = "0.16.0", optional = true }
ewebsock = { version = "0.6.0", features = ["tls"] }
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "ee8afeeb0b6695fca6d27dd0b74a8dc159e37b95" }
rand = "0.8.5"
nostr = { version = "0.32.1", features = ["std"] }
nostr = { version = "0.32.1", features = ["std", "nip59"] }
serde = "1.0.204"
serde_json = "1.0.121"

26
shell.nix Normal file
View file

@ -0,0 +1,26 @@
{ pkgs ? import <nixpkgs> { }
}:
with pkgs;
let
x11libs = lib.makeLibraryPath [ xorg.libX11 xorg.libXcursor xorg.libXrandr xorg.libXi libglvnd vulkan-loader vulkan-validation-layers libxkbcommon ];
in
mkShell ({
nativeBuildInputs = [
rustup
rustfmt
libiconv
pkg-config
fontconfig
] ++ lib.optional stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.OpenGL
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.AppKit
];
} // (
lib.optionalAttrs (!stdenv.isDarwin) {
LD_LIBRARY_PATH = "${x11libs}";
}
))

34
src/mail_event.rs Normal file
View file

@ -0,0 +1,34 @@
use std::collections::HashMap;
use nostr::{EventBuilder, Event, PublicKey, Kind, Tag, Keys};
pub const MAIL_EVENT_KIND: u16 = 1059;
pub struct MailMessage {
to: Vec<PublicKey>,
cc: Vec<PublicKey>,
bcc: Vec<PublicKey>,
subject: String,
content: String,
}
impl MailMessage {
pub fn to_events(&mut self, sending_keys: &Keys) -> HashMap<PublicKey, Event> {
let mut pubkeys_to_send_to: Vec<PublicKey> = Vec::new();
let mut tags: Vec<Tag> = Vec::new();
for pubkey in &self.to {
tags.push(Tag::public_key(*pubkey));
pubkeys_to_send_to.push(*pubkey);
}
let base_event = EventBuilder::new(Kind::Custom(MAIL_EVENT_KIND), &self.content, []).to_unsigned_event(sending_keys.clone().public_key());
let mut event_list: HashMap<PublicKey, Event> = HashMap::new();
for pubkey in pubkeys_to_send_to {
let wrapped_event = EventBuilder::gift_wrap(sending_keys, &pubkey, base_event.clone(), None).unwrap();
event_list.insert(pubkey, wrapped_event);
}
event_list
}
}

View file

@ -10,6 +10,7 @@ mod error;
mod keystorage;
mod relay;
mod ui;
mod mail_event;
fn main() -> Result<(), eframe::Error> {
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); // add log files in prod one day