Add 'euph.rooms.<name>.force_username' config option
This commit is contained in:
parent
d0ba210855
commit
6150d05255
4 changed files with 9 additions and 7 deletions
|
|
@ -19,6 +19,7 @@ Procedure when bumping the version number:
|
||||||
- `ephemeral` config option
|
- `ephemeral` config option
|
||||||
- `data_dir` config option
|
- `data_dir` config option
|
||||||
- `euph.rooms.<name>.username` config option
|
- `euph.rooms.<name>.username` config option
|
||||||
|
- `euph.rooms.<name>.force_username` config option
|
||||||
- `euph.rooms.<name>.password` config option
|
- `euph.rooms.<name>.password` config option
|
||||||
|
|
||||||
## v0.3.0 - 2022-08-22
|
## v0.3.0 - 2022-08-22
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ use crate::macros::ok_or_return;
|
||||||
#[derive(Debug, Clone, Default, Deserialize)]
|
#[derive(Debug, Clone, Default, Deserialize)]
|
||||||
pub struct EuphRoom {
|
pub struct EuphRoom {
|
||||||
pub username: Option<String>,
|
pub username: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub force_username: bool,
|
||||||
pub password: Option<String>,
|
pub password: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ enum Event {
|
||||||
struct State {
|
struct State {
|
||||||
name: String,
|
name: String,
|
||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
|
force_username: bool,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
vault: EuphVault,
|
vault: EuphVault,
|
||||||
|
|
||||||
|
|
@ -287,13 +288,8 @@ impl State {
|
||||||
let own_user_id = self.own_user_id().await;
|
let own_user_id = self.own_user_id().await;
|
||||||
self.vault.add_messages(d.log.clone(), None, own_user_id);
|
self.vault.add_messages(d.log.clone(), None, own_user_id);
|
||||||
|
|
||||||
if d.nick.is_none() {
|
if let Some(username) = &self.username {
|
||||||
// Avoid overwriting nicks that the euphoria backend already
|
if self.force_username || d.nick.is_none() {
|
||||||
// knows, e. g. because the user set it while logged in via
|
|
||||||
// the browser. This setting is mostly meant for ephemeral
|
|
||||||
// mode. Maybe I'll add a "force_nick" setting at some point
|
|
||||||
// in the future?
|
|
||||||
if let Some(username) = &self.username {
|
|
||||||
self.on_nick(username.clone());
|
self.on_nick(username.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -434,6 +430,7 @@ impl Room {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
vault: EuphVault,
|
vault: EuphVault,
|
||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
|
force_username: bool,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
) -> (Self, mpsc::UnboundedReceiver<EuphRoomEvent>) {
|
) -> (Self, mpsc::UnboundedReceiver<EuphRoomEvent>) {
|
||||||
let (canary_tx, canary_rx) = oneshot::channel();
|
let (canary_tx, canary_rx) = oneshot::channel();
|
||||||
|
|
@ -444,6 +441,7 @@ impl Room {
|
||||||
let state = State {
|
let state = State {
|
||||||
name: vault.room().to_string(),
|
name: vault.room().to_string(),
|
||||||
username,
|
username,
|
||||||
|
force_username,
|
||||||
password,
|
password,
|
||||||
vault,
|
vault,
|
||||||
conn_tx: None,
|
conn_tx: None,
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ impl EuphRoom {
|
||||||
let (room, euph_room_event_rx) = euph::Room::new(
|
let (room, euph_room_event_rx) = euph::Room::new(
|
||||||
store,
|
store,
|
||||||
self.config.username.clone(),
|
self.config.username.clone(),
|
||||||
|
self.config.force_username,
|
||||||
self.config.password.clone(),
|
self.config.password.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue