update concord bcakend
This commit is contained in:
@@ -17,8 +17,8 @@ pub const KIND_SEAL_PLAINTEXT: u16 = 20014;
|
||||
pub const NIP44_MAX_PLAINTEXT: usize = 65_535;
|
||||
|
||||
const TAG_MS: &str = "ms";
|
||||
const TAG_CHANNEL: &str = "channel";
|
||||
const TAG_EPOCH: &str = "epoch";
|
||||
pub(crate) const TAG_CHANNEL: &str = "channel";
|
||||
pub(crate) const TAG_EPOCH: &str = "epoch";
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SealForm {
|
||||
@@ -420,7 +420,10 @@ fn check_plaintext_cap(len: usize) -> Result<(), StreamError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unique_tag(rumor: &UnsignedEvent, name: &'static str) -> Result<Option<String>, StreamError> {
|
||||
pub(crate) fn unique_tag(
|
||||
rumor: &UnsignedEvent,
|
||||
name: &'static str,
|
||||
) -> Result<Option<String>, StreamError> {
|
||||
let mut found: Option<String> = None;
|
||||
|
||||
for tag in rumor.tags.iter() {
|
||||
|
||||
@@ -5,8 +5,9 @@ use anyhow::Result;
|
||||
use nostr_sdk::prelude::*;
|
||||
|
||||
use crate::cord01::{
|
||||
KIND_WRAP, KIND_WRAP_EPHEMERAL, OpenedStream, SealForm, build_rumor_ms, build_seal,
|
||||
channel_binding_tags, check_channel_binding, open_wrap, resolve_ms_strict, wrap_seal,
|
||||
KIND_WRAP, KIND_WRAP_EPHEMERAL, OpenedStream, SealForm, TAG_CHANNEL, TAG_EPOCH, build_rumor_ms,
|
||||
build_seal, channel_binding_tags, check_channel_binding, open_wrap, resolve_ms_strict,
|
||||
unique_tag, wrap_seal,
|
||||
};
|
||||
use crate::cord04::{AuthorityCitation, canonical_decimal, citation_tag};
|
||||
pub use crate::cords::rumor::RumorError as ChatError;
|
||||
@@ -313,6 +314,20 @@ pub fn open(
|
||||
Ok((opened, chat))
|
||||
}
|
||||
|
||||
/// Rebuild a rumor from a locally-cached copy: the binding tags name its channel and epoch.
|
||||
pub fn parse_rumor(rumor: &UnsignedEvent) -> Result<ChatRumor, ChatError> {
|
||||
let channel: ChannelId = unique_tag(rumor, TAG_CHANNEL)?
|
||||
.ok_or(ChatError::MissingTag(TAG_CHANNEL))?
|
||||
.parse()
|
||||
.map_err(|_| ChatError::BadTag(TAG_CHANNEL))?;
|
||||
|
||||
let epoch = unique_tag(rumor, TAG_EPOCH)?
|
||||
.ok_or(ChatError::MissingTag(TAG_EPOCH))
|
||||
.and_then(|raw| canonical_decimal(&raw).ok_or(ChatError::BadTag(TAG_EPOCH)))?;
|
||||
|
||||
typed(rumor, &channel, Epoch(epoch))
|
||||
}
|
||||
|
||||
/// `secret` is the `community_root` for a public channel, its own key for a private one.
|
||||
pub fn plane_keys(
|
||||
held: &[(Epoch, [u8; 32])],
|
||||
|
||||
Reference in New Issue
Block a user