Add 'euph.rooms.<name>.username' config option
This commit is contained in:
parent
6e6fddc0b1
commit
d0ba210855
4 changed files with 21 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ Procedure when bumping the version number:
|
||||||
- Config file
|
- Config file
|
||||||
- `ephemeral` config option
|
- `ephemeral` config option
|
||||||
- `data_dir` config option
|
- `data_dir` config option
|
||||||
|
- `euph.rooms.<name>.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
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ 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 password: Option<String>,
|
pub password: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ enum Event {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct State {
|
struct State {
|
||||||
name: String,
|
name: String,
|
||||||
|
username: Option<String>,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
vault: EuphVault,
|
vault: EuphVault,
|
||||||
|
|
||||||
|
|
@ -285,6 +286,17 @@ impl State {
|
||||||
self.last_msg_id = Some(d.log.last().map(|m| m.id));
|
self.last_msg_id = Some(d.log.last().map(|m| m.id));
|
||||||
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() {
|
||||||
|
// Avoid overwriting nicks that the euphoria backend already
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Data::LogReply(d) => {
|
Data::LogReply(d) => {
|
||||||
let own_user_id = self.own_user_id().await;
|
let own_user_id = self.own_user_id().await;
|
||||||
|
|
@ -421,6 +433,7 @@ pub struct Room {
|
||||||
impl Room {
|
impl Room {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
vault: EuphVault,
|
vault: EuphVault,
|
||||||
|
username: Option<String>,
|
||||||
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();
|
||||||
|
|
@ -430,6 +443,7 @@ impl Room {
|
||||||
|
|
||||||
let state = State {
|
let state = State {
|
||||||
name: vault.room().to_string(),
|
name: vault.room().to_string(),
|
||||||
|
username,
|
||||||
password,
|
password,
|
||||||
vault,
|
vault,
|
||||||
conn_tx: None,
|
conn_tx: None,
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,11 @@ impl EuphRoom {
|
||||||
if self.room.is_none() {
|
if self.room.is_none() {
|
||||||
let store = self.chat.store().clone();
|
let store = self.chat.store().clone();
|
||||||
let name = store.room().to_string();
|
let name = store.room().to_string();
|
||||||
let (room, euph_room_event_rx) = euph::Room::new(store, self.config.password.clone());
|
let (room, euph_room_event_rx) = euph::Room::new(
|
||||||
|
store,
|
||||||
|
self.config.username.clone(),
|
||||||
|
self.config.password.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
self.room = Some(room);
|
self.room = Some(room);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue