Commit 4c5705381f
Unsigned
Layout: unified · split
src/render.rs +23 −1
| @@ -32,6 +32,28 @@ pub struct RenderedEvent { | ||
| 32 | 32 | pub content: RenderedContent, |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | impl RenderedEvent { | |
| 36 | const MSG_TAGS: &'static [&'static str] = &["notify_message"]; | |
| 37 | const SELF_TAGS: &'static [&'static str] = | |
| 38 | &["notify_none", "no_highlight", "self_msg"]; | |
| 39 | ||
| 40 | pub fn add_self_tags(self) -> Self { | |
| 41 | self.add_tags(Self::SELF_TAGS) | |
| 42 | } | |
| 43 | ||
| 44 | pub fn add_msg_tags(self) -> Self { | |
| 45 | self.add_tags(Self::MSG_TAGS) | |
| 46 | } | |
| 47 | ||
| 48 | fn add_tags(mut self, tags: &[&str]) -> Self { | |
| 49 | for line in &mut self.content.lines { | |
| 50 | line.tags.extend(tags.iter().map(|tag| tag.to_string())) | |
| 51 | } | |
| 52 | ||
| 53 | self | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 35 | 57 | pub struct RenderedLine { |
| 36 | 58 | /// The tags of the line. |
| 37 | 59 | pub tags: Vec<String>, |
| @@ -322,7 +344,7 @@ impl Render for EncryptedEventContent { | ||
| 322 | 344 | |
| 323 | 345 | impl Render for RedactedSyncMessageEvent<RedactedMessageEventContent> { |
| 324 | 346 | type RenderContext = WeechatRoomMember; |
| 325 | const TAGS: &'static [&'static str] = &[&"matrix_redacted"]; | |
| 347 | const TAGS: &'static [&'static str] = &["matrix_redacted"]; | |
| 326 | 348 | |
| 327 | 349 | fn render(&self, redacter: &Self::RenderContext) -> RenderedContent { |
| 328 | 350 | // TODO add the redaction reason. |
src/room/mod.rs +10 −2
| @@ -502,7 +502,14 @@ impl MatrixRoom { | ||
| 502 | 502 | &sender, |
| 503 | 503 | &event.content(), |
| 504 | 504 | ) |
| 505 | .await | |
| 505 | .await.map(|r| { | |
| 506 | // TODO the tags are different if the room is a DM. | |
| 507 | if sender.user_id == self.own_user_id { | |
| 508 | r.add_self_tags() | |
| 509 | } else { | |
| 510 | r.add_msg_tags() | |
| 511 | } | |
| 512 | }) | |
| 506 | 513 | } |
| 507 | 514 | |
| 508 | 515 | // Add the content of the message to our outgoing messag queue and print out |
| @@ -520,7 +527,8 @@ impl MatrixRoom { | ||
| 520 | 527 | }); |
| 521 | 528 | |
| 522 | 529 | let local_echo = |
| 523 | c.render_with_prefix_for_echo(&sender, uuid, &()); | |
| 530 | c.render_with_prefix_for_echo(&sender, uuid, &()) | |
| 531 | .add_self_tags(); | |
| 524 | 532 | self.print_rendered_event(local_echo); |
| 525 | 533 | |
| 526 | 534 | self.outgoing_messages.add_with_echo(uuid, content.clone()); |