11##
2- # Copyright (C) 2021-2022 Valentin Lorentz
2+ # Copyright (C) 2021-2023 Valentin Lorentz
33#
44# This program is free software: you can redistribute it and/or modify
55# it under the terms of the GNU Affero General Public License version 3,
@@ -2288,7 +2288,7 @@ defmodule M51.MatrixClient.PollerTest do
22882288 } )
22892289
22902290 assert_line ( ":nick:[email protected] PRIVMSG #test:example.org :first message\r \n " ) 2291- # m.room.redaction not implemented yet , so it's just ignored
2291+ # We'll probably see the m.room.redaction message later , so we can simply ignore this one.
22922292 assert_line (
22932293 ":nick:[email protected] PRIVMSG #test:example.org :second message\r \n " 22942294 )
@@ -2297,6 +2297,71 @@ defmodule M51.MatrixClient.PollerTest do
22972297 end
22982298
22992299 test "message redaction" do
2300+ M51.IrcConn.State . add_capabilities ( :process_ircconn_state , [
2301+ :multiline ,
2302+ :message_tags ,
2303+ :message_redaction
2304+ ] )
2305+
2306+ joined_room ( )
2307+
2308+ timeline_events = [
2309+ % {
2310+ "content" => % { "body" => "first message" , "msgtype" => "m.text" } ,
2311+ "event_id" => "$event1" ,
2312+ "origin_server_ts" => 1_632_946_233_579 ,
2313+ "sender" => "@nick:example.org" ,
2314+ "type" => "m.room.message" ,
2315+ "unsigned" => % { }
2316+ } ,
2317+ % {
2318+ "content" => % { } ,
2319+ "event_id" => "$event2" ,
2320+ "redacts" => "$event1" ,
2321+ "origin_server_ts" => 1_633_808_172_505 ,
2322+ "sender" => "@admin:example.org" ,
2323+ "type" => "m.room.redaction" ,
2324+ "unsigned" => % { }
2325+ } ,
2326+ % {
2327+ "content" => % {
2328+ "reason" => "Redacting again!"
2329+ } ,
2330+ "event_id" => "$event3" ,
2331+ "redacts" => "$event1" ,
2332+ "origin_server_ts" => 1_633_808_172_505 ,
2333+ "sender" => "@admin:example.org" ,
2334+ "type" => "m.room.redaction" ,
2335+ "unsigned" => % { }
2336+ }
2337+ ]
2338+
2339+ M51.MatrixClient.Poller . handle_events ( self ( ) , false , % {
2340+ "rooms" => % {
2341+ "join" => % {
2342+ "!testid:example.org" => % {
2343+ "timeline" => % { "events" => timeline_events }
2344+ }
2345+ }
2346+ }
2347+ } )
2348+
2349+ assert_line (
2350+ "@msgid=$event1 :nick:[email protected] PRIVMSG #test:example.org :first message\r \n " 2351+ )
2352+
2353+ assert_line (
2354+ "@msgid=$event2 :admin:[email protected] REDACT #test:example.org :$event1\r \n " 2355+ )
2356+
2357+ assert_line (
2358+ "@msgid=$event3 :admin:[email protected] REDACT #test:example.org $event1 :Redacting again!\r \n " 2359+ )
2360+
2361+ assert_last_line ( )
2362+ end
2363+
2364+ test "message redaction fallback" do
23002365 M51.IrcConn.State . add_capabilities ( :process_ircconn_state , [
23012366 :multiline ,
23022367 :message_tags
0 commit comments