mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-14 01:03:47 +00:00
Option to add tag ["client","gossip"] to posts, off by default. This may help us get feedback about certain kinds of issues.
This commit is contained in:
parent
5c1fc6a510
commit
f2f3855c77
@ -619,7 +619,7 @@ impl Overlord {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn post_textnote(&mut self, content: String, tags: Vec<Tag>) -> Result<(), Error> {
|
||||
async fn post_textnote(&mut self, content: String, mut tags: Vec<Tag>) -> Result<(), Error> {
|
||||
let event = {
|
||||
let public_key = match GLOBALS.signer.read().await.public_key() {
|
||||
Some(pk) => pk,
|
||||
@ -629,6 +629,13 @@ impl Overlord {
|
||||
}
|
||||
};
|
||||
|
||||
if GLOBALS.settings.read().await.set_client_tag {
|
||||
tags.push(Tag::Other {
|
||||
tag: "client".to_owned(),
|
||||
data: vec!["gossip".to_owned()],
|
||||
});
|
||||
}
|
||||
|
||||
let pre_event = PreEvent {
|
||||
pubkey: public_key,
|
||||
created_at: Unixtime::now().unwrap(),
|
||||
@ -725,6 +732,13 @@ impl Overlord {
|
||||
|
||||
// FIXME deduplicate 'p' tags
|
||||
|
||||
if GLOBALS.settings.read().await.set_client_tag {
|
||||
tags.push(Tag::Other {
|
||||
tag: "client".to_owned(),
|
||||
data: vec!["gossip".to_owned()],
|
||||
});
|
||||
}
|
||||
|
||||
let pre_event = PreEvent {
|
||||
pubkey: public_key,
|
||||
created_at: Unixtime::now().unwrap(),
|
||||
@ -778,11 +792,7 @@ impl Overlord {
|
||||
}
|
||||
};
|
||||
|
||||
let pre_event = PreEvent {
|
||||
pubkey: public_key,
|
||||
created_at: Unixtime::now().unwrap(),
|
||||
kind: EventKind::Reaction,
|
||||
tags: vec![
|
||||
let mut tags: Vec<Tag> = vec![
|
||||
Tag::Event {
|
||||
id,
|
||||
recommended_relay_url: DbRelay::recommended_relay_for_reply(id).await?,
|
||||
@ -793,7 +803,20 @@ impl Overlord {
|
||||
recommended_relay_url: None,
|
||||
petname: None,
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
if GLOBALS.settings.read().await.set_client_tag {
|
||||
tags.push(Tag::Other {
|
||||
tag: "client".to_owned(),
|
||||
data: vec!["gossip".to_owned()],
|
||||
});
|
||||
}
|
||||
|
||||
let pre_event = PreEvent {
|
||||
pubkey: public_key,
|
||||
created_at: Unixtime::now().unwrap(),
|
||||
kind: EventKind::Reaction,
|
||||
tags,
|
||||
content: "+".to_owned(),
|
||||
ots: None,
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ pub const DEFAULT_FEED_RECOMPUTE_INTERVAL_MS: u32 = 2000;
|
||||
pub const DEFAULT_POW: u8 = 0;
|
||||
pub const DEFAULT_OFFLINE: bool = false;
|
||||
pub const DEFAULT_LIGHT_MODE: bool = true; // true = light false = dark
|
||||
pub const DEFAULT_SET_CLIENT_TAG: bool = false;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Settings {
|
||||
@ -30,6 +31,7 @@ pub struct Settings {
|
||||
pub pow: u8,
|
||||
pub offline: bool,
|
||||
pub light_mode: bool,
|
||||
pub set_client_tag: bool,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
@ -48,6 +50,7 @@ impl Default for Settings {
|
||||
pow: DEFAULT_POW,
|
||||
offline: DEFAULT_OFFLINE,
|
||||
light_mode: DEFAULT_LIGHT_MODE,
|
||||
set_client_tag: DEFAULT_SET_CLIENT_TAG,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,6 +108,7 @@ impl Settings {
|
||||
"pow" => settings.pow = row.1.parse::<u8>().unwrap_or(DEFAULT_POW),
|
||||
"offline" => settings.offline = numstr_to_bool(row.1),
|
||||
"light_mode" => settings.light_mode = numstr_to_bool(row.1),
|
||||
"set_client_tag" => settings.set_client_tag = numstr_to_bool(row.1),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -135,8 +139,9 @@ impl Settings {
|
||||
('max_fps', ?),\
|
||||
('feed_recompute_interval_ms', ?),\
|
||||
('pow', ?),\
|
||||
('offline', ?),\
|
||||
('light_mode', ?),\
|
||||
('offline', ?)",
|
||||
('set_client_tag', ?)",
|
||||
)?;
|
||||
stmt.execute((
|
||||
self.feed_chunk,
|
||||
@ -148,8 +153,9 @@ impl Settings {
|
||||
self.max_fps,
|
||||
self.feed_recompute_interval_ms,
|
||||
self.pow,
|
||||
bool_to_numstr(self.light_mode),
|
||||
bool_to_numstr(self.offline),
|
||||
bool_to_numstr(self.light_mode),
|
||||
bool_to_numstr(self.set_client_tag),
|
||||
))?;
|
||||
|
||||
// Save private key identity
|
||||
|
@ -5,12 +5,7 @@ use eframe::egui;
|
||||
use egui::widgets::{Button, Slider};
|
||||
use egui::{Align, Context, Layout, Ui};
|
||||
|
||||
pub(super) fn update(
|
||||
app: &mut GossipUi,
|
||||
_ctx: &Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
ui.heading("Settings");
|
||||
|
||||
ui.add_space(12.0);
|
||||
@ -93,6 +88,14 @@ pub(super) fn update(
|
||||
ui.add(Slider::new(&mut app.settings.pow, 0..=40).text("leading zeroes"));
|
||||
});
|
||||
|
||||
ui.add_space(12.0);
|
||||
|
||||
ui.checkbox(
|
||||
&mut app.settings.set_client_tag,
|
||||
"Add tag [\"client\",\"gossip\"] to posts",
|
||||
)
|
||||
.on_hover_text("Takes effect immediately.");
|
||||
|
||||
ui.add_space(12.0);
|
||||
ui.separator();
|
||||
ui.add_space(12.0);
|
||||
|
Loading…
Reference in New Issue
Block a user