summaryrefslogtreecommitdiffstats
path: root/src/repository/mod.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-19 18:32:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-10-21 14:54:29 +0200
commit95f48d97f52ddd2528d2f556fb9abd1149f727e3 (patch)
tree63e28d548775d728b51164f867d73be01c77dca7 /src/repository/mod.rs
parent46c57244a24a183c04a9b540e42c30b4e70866d0 (diff)
WIP: Implement "post" subcommand
Diffstat (limited to 'src/repository/mod.rs')
-rw-r--r--src/repository/mod.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/repository/mod.rs b/src/repository/mod.rs
index 99dc858..f4a6684 100644
--- a/src/repository/mod.rs
+++ b/src/repository/mod.rs
@@ -16,11 +16,13 @@ use futures::stream::Stream;
use serde_json::from_str as serde_json_from_str;
use serde_json::to_string as serde_json_to_str;
use serde::Serialize;
+use chrono::NaiveDateTime;
use types::block::Block;
use types::content::Content;
use types::content::Payload;
use types::util::IPFSHash;
+use types::util::IPNSHash;
use version::protocol_version;
// use repository::iter::BlockIter;
@@ -32,7 +34,7 @@ pub struct Repository {
client: Arc<IpfsClient>,
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProfileName(String);
impl Deref for ProfileName {
@@ -44,7 +46,7 @@ impl Deref for ProfileName {
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProfileKey(String);
impl Deref for ProfileKey {
@@ -88,6 +90,13 @@ impl Repository {
::repository::client::resolve_block(self.client.clone(), hash)
}
+ pub fn resolve_latest_block(&self, hash: &IPNSHash)
+ -> impl Future<Item = Block, Error = Error>
+ {
+ debug!("Resolving latest block: {}", hash);
+ ::repository::client::resolve_latest_block(self.client.clone(), hash)
+ }
+
/// Gets a types::Content from a hash or fails
pub fn resolve_content(&self, hash: &IPFSHash)
-> impl Future<Item = Content, Error = Error>
@@ -232,4 +241,25 @@ impl Repository {
::futures::future::Either::A(result)
}
+ pub fn new_text_post<'a>(&'a self,
+ publish_key_id: ProfileKey,
+ latest_block: IPFSHash,
+ text: String,
+ time: Option<NaiveDateTime>)
+ -> impl Future<Item = (), Error = Error>
+ {
+ debug!("New text post under {:?}, after block {:?}", publish_key_id, latest_block);
+ ::repository::client::new_text_post(self.client.clone(),
+ publish_key_id,
+ latest_block,
+ text,
+ time)
+ }
+
+ pub fn get_key_id_from_key_name<'a>(&'a self, name: ProfileName)
+ -> impl Future<Item = ProfileKey, Error = Error>
+ {
+ ::repository::client::get_key_id_from_key_name(self.client.clone(), name)
+ }
+
}