s2s: handle echo's metadata profile keys, standard replies, OPERTYPE and REDACT; emit ssl_cert + OPERTYPE
This commit is contained in:
parent
8f765bfba7
commit
5722640957
4 changed files with 157 additions and 12 deletions
|
|
@ -66,6 +66,16 @@ pub fn record(
|
|||
}
|
||||
}
|
||||
|
||||
/// Drop a message from a conversation's history by msgid (a redaction), so replays
|
||||
/// don't resurrect it. Used by both the client REDACT command and an inbound S2S REDACT.
|
||||
pub fn forget(s: &mut Server, key: &str, msgid: &str) {
|
||||
if let Some(h) = s.ext.get_mut::<History>() {
|
||||
if let Some(buf) = h.0.get_mut(key) {
|
||||
buf.retain(|m| m.msgid != msgid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Canonical CHATHISTORY key for a DM between two nicks (order-independent; the
|
||||
/// `\0` prefix keeps it from ever colliding with a `#channel` key).
|
||||
pub fn dm_key(a: &str, b: &str) -> String {
|
||||
|
|
|
|||
|
|
@ -220,6 +220,34 @@ impl Command for MetadataCmd {
|
|||
}
|
||||
}
|
||||
|
||||
/// Apply a metadata key pushed onto a local user from services (or another server)
|
||||
/// and echo the change to that user if they negotiated the metadata cap. Backs the
|
||||
/// profile keys (avatar/bio/pronouns/timezone/url) that NickServ SET populates, so
|
||||
/// they surface over draft/metadata-2 instead of being dropped on the link.
|
||||
pub fn apply_user(s: &mut Server, uid: Uid, nick: &str, mkey: &str, value: Option<&str>, setter: &str) {
|
||||
let sk = format!("u{uid}");
|
||||
{
|
||||
let st = s.ext.get_or_insert_with::<MetaStore>(MetaStore::default);
|
||||
match value {
|
||||
Some(v) => {
|
||||
st.0.entry(sk).or_default().insert(mkey.to_string(), v.to_string());
|
||||
}
|
||||
None => {
|
||||
if let Some(m) = st.0.get_mut(&sk) {
|
||||
m.remove(mkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if s.users.get(&uid).map(|u| u.caps.metadata).unwrap_or(false) {
|
||||
let note = match value {
|
||||
Some(v) => format!(":{setter} METADATA {nick} {mkey} * :{v}"),
|
||||
None => format!(":{setter} METADATA {nick} {mkey} *"),
|
||||
};
|
||||
s.send(uid, note);
|
||||
}
|
||||
}
|
||||
|
||||
/// Where channel metadata is persisted (beside the config).
|
||||
fn db_path(s: &Server) -> String {
|
||||
format!("{}.metadata", s.conf_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue