1use once_cell::sync::Lazy;
4use serde_json::{json, Value as JsonValue};
5
6use crate::DEFAULT_TEST_ROOM_ID;
7
8pub static ALIAS: Lazy<JsonValue> = Lazy::new(|| {
9 json!({
10 "content": {
11 "alias": "#tutorial:localhost"
12 },
13 "event_id": "$15139375513VdeRF:localhost",
14 "origin_server_ts": 151393755,
15 "sender": "@example:localhost",
16 "state_key": "",
17 "type": "m.room.canonical_alias",
18 "unsigned": {
19 "age": 703422
20 }
21 })
22});
23
24pub static ALIASES: Lazy<JsonValue> = Lazy::new(|| {
25 json!({
26 "content": {
27 "aliases": [
28 "#tutorial:localhost"
29 ]
30 },
31 "event_id": "$15139375516NUgtD:localhost",
32 "origin_server_ts": 151393755,
33 "sender": "@example:localhost",
34 "state_key": "localhost",
35 "type": "m.room.aliases",
36 "unsigned": {
37 "age": 703422
38 }
39 })
40});
41
42pub static CREATE: Lazy<JsonValue> = Lazy::new(|| {
43 json!({
44 "content": {
45 "creator": "@example:localhost",
46 "m.federate": true,
47 "room_version": "1"
48 },
49 "event_id": "$151957878228ekrDs:localhost",
50 "origin_server_ts": 15195787,
51 "sender": "@example:localhost",
52 "state_key": "",
53 "type": "m.room.create",
54 "unsigned": {
55 "age": 139298
56 }
57 })
58});
59
60pub static DIRECT: Lazy<JsonValue> = Lazy::new(|| {
61 json!({
62 "content": {
63 "@invited:localhost": [*DEFAULT_TEST_ROOM_ID],
64 },
65 "event_id": "$757957878228ekrDs:localhost",
66 "origin_server_ts": 17195787,
67 "sender": "@example:localhost",
68 "state_key": "",
69 "type": "m.direct",
70 "unsigned": {
71 "age": 139298
72 }
73 })
74});
75
76pub static FULLY_READ: Lazy<JsonValue> = Lazy::new(|| {
77 json!({
78 "content": {
79 "event_id": "$someplace:example.org"
80 },
81 "room_id": "!somewhere:example.org",
82 "type": "m.fully_read"
83 })
84});
85
86pub static HISTORY_VISIBILITY: Lazy<JsonValue> = Lazy::new(|| {
87 json!({
88 "content": {
89 "history_visibility": "world_readable"
90 },
91 "event_id": "$151957878235ricnD:localhost",
92 "origin_server_ts": 151957878,
93 "sender": "@example:localhost",
94 "state_key": "",
95 "type": "m.room.history_visibility",
96 "unsigned": {
97 "age": 1392989
98 }
99 })
100});
101
102pub static JOIN_RULES: Lazy<JsonValue> = Lazy::new(|| {
103 json!({
104 "content": {
105 "join_rule": "public"
106 },
107 "event_id": "$151957878231iejdB:localhost",
108 "origin_server_ts": 151957878,
109 "sender": "@example:localhost",
110 "state_key": "",
111 "type": "m.room.join_rules",
112 "unsigned": {
113 "age": 1392989
114 }
115 })
116});
117
118pub static ENCRYPTION_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
119 json!({
120 "algorithm": "m.megolm.v1.aes-sha2",
121 "rotation_period_ms": 604800000,
122 "rotation_period_msgs": 100
123 })
124});
125
126pub static ENCRYPTION: Lazy<JsonValue> = Lazy::new(|| {
127 json!({
128 "content": *ENCRYPTION_CONTENT,
129 "event_id": "$143273582443PhrSn:example.org",
130 "origin_server_ts": 1432735824653u64,
131 "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
132 "sender": "@example:example.org",
133 "state_key": "",
134 "type": "m.room.encryption",
135 "unsigned": {
136 "age": 1234
137 }
138 })
139});
140
141pub static MEMBER: Lazy<JsonValue> = Lazy::new(|| {
143 json!({
144 "content": {
145 "avatar_url": null,
146 "displayname": "example",
147 "membership": "join"
148 },
149 "event_id": "$151800140517rfvjc:localhost",
150 "membership": "join",
151 "origin_server_ts": 151800140,
152 "sender": "@example:localhost",
153 "state_key": "@example:localhost",
154 "type": "m.room.member",
155 "prev_content": {
156 "avatar_url": null,
157 "displayname": "example",
158 "membership": "invite"
159 },
160 "unsigned": {
161 "age": 297036,
162 "replaces_state": "$151800111315tsynI:localhost"
163 }
164 })
165});
166
167pub static MEMBER_ADDITIONAL: Lazy<JsonValue> = Lazy::new(|| {
169 json!({
170 "content": {
171 "membership": "join",
172 },
173 "event_id": "$747273582443PhrSn:localhost",
174 "origin_server_ts": 1472735824,
175 "sender": "@example:localhost",
176 "state_key": "@invited:localhost",
177 "type": "m.room.member",
178 "unsigned": {
179 "age": 1234
180 }
181 })
182});
183
184pub static MEMBER_LEAVE: Lazy<JsonValue> = Lazy::new(|| {
186 json!({
187 "content": {
188 "membership": "leave",
189 },
190 "event_id": "$747273582443PhrS9:localhost",
191 "origin_server_ts": 1472735820,
192 "sender": "@example:localhost",
193 "state_key": "@invited:localhost",
194 "type": "m.room.member",
195 "unsigned": {
196 "age": 1234
197 }
198 })
199});
200
201pub static MEMBER_BAN: Lazy<JsonValue> = Lazy::new(|| {
202 json!({
203 "content": {
204 "avatar_url": null,
205 "displayname": "example",
206 "membership": "ban"
207 },
208 "event_id": "$151800140517rfvjc:localhost",
209 "origin_server_ts": 151800140,
210 "sender": "@example:localhost",
211 "state_key": "@banned:localhost",
212 "type": "m.room.member",
213 })
214});
215
216pub static MEMBER_INVITE: Lazy<JsonValue> = Lazy::new(|| {
217 json!({
218 "content": {
219 "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF",
220 "displayname": "example",
221 "membership": "invite",
222 "reason": "Looking for support"
223 },
224 "event_id": "$143273582443PhrSn:localhost",
225 "origin_server_ts": 1432735824,
226 "room_id": "!jEsUZKDJdhlrceRyVU:localhost",
227 "sender": "@example:localhost",
228 "state_key": "@invited:localhost",
229 "type": "m.room.member",
230 "unsigned": {
231 "age": 1234,
232 "invite_room_state": [
233 {
234 "content": {
235 "name": "Example Room"
236 },
237 "sender": "@example:localhost",
238 "state_key": "",
239 "type": "m.room.name"
240 },
241 {
242 "content": {
243 "join_rule": "invite"
244 },
245 "sender": "@example:localhost",
246 "state_key": "",
247 "type": "m.room.join_rules"
248 }
249 ]
250 }
251 })
252});
253
254pub static MEMBER_NAME_CHANGE: Lazy<JsonValue> = Lazy::new(|| {
256 json!({
257 "content": {
258 "avatar_url": null,
259 "displayname": "changed",
260 "membership": "join"
261 },
262 "event_id": "$151800234427abgho:localhost",
263 "membership": "join",
264 "origin_server_ts": 151800152,
265 "sender": "@example:localhost",
266 "state_key": "@example:localhost",
267 "type": "m.room.member",
268 "prev_content": {
269 "avatar_url": null,
270 "displayname": "example",
271 "membership": "join"
272 },
273 "unsigned": {
274 "age": 297032,
275 "replaces_state": "$151800140517rfvjc:localhost"
276 }
277 })
278});
279
280pub static MEMBER_STRIPPED: Lazy<JsonValue> = Lazy::new(|| {
281 json!({
282 "content": {
283 "avatar_url": null,
284 "displayname": "example",
285 "membership": "join"
286 },
287 "sender": "@example:localhost",
288 "state_key": "@example:localhost",
289 "type": "m.room.member",
290 })
291});
292
293pub static NAME: Lazy<JsonValue> = Lazy::new(|| {
294 json!({
295 "content": {
296 "name": "room name"
297 },
298 "event_id": "$15139375513VdeRF:localhost",
299 "origin_server_ts": 151393755,
300 "sender": "@example:localhost",
301 "state_key": "",
302 "type": "m.room.name",
303 "unsigned": {
304 "age": 703422
305 }
306 })
307});
308
309pub static NAME_STRIPPED: Lazy<JsonValue> = Lazy::new(|| {
310 json!({
311 "content": {
312 "name": "room name"
313 },
314 "sender": "@example:localhost",
315 "state_key": "",
316 "type": "m.room.name",
317 })
318});
319
320pub static PINNED_EVENTS: Lazy<JsonValue> = Lazy::new(|| {
321 json!({
322 "content": {
323 "pinned": [ "$a", "$b" ]
324 },
325 "event_id": "$15139375513VdeRF:localhost",
326 "origin_server_ts": 151393755,
327 "sender": "@example:localhost",
328 "state_key": "",
329 "type": "m.room.pinned_events",
330 "unsigned": {
331 "age": 703422
332 }
333 })
334});
335
336pub static POWER_LEVELS: Lazy<JsonValue> = Lazy::new(|| {
337 json!({
338 "content": {
339 "ban": 50,
340 "events": {
341 "m.room.avatar": 50,
342 "m.room.canonical_alias": 50,
343 "m.room.history_visibility": 100,
344 "m.room.name": 50,
345 "m.room.power_levels": 100,
346 "m.room.message": 25
347 },
348 "events_default": 0,
349 "invite": 0,
350 "kick": 50,
351 "redact": 50,
352 "state_default": 50,
353 "notifications": {
354 "room": 0
355 },
356 "users": {
357 "@example:localhost": 100,
358 "@bob:localhost": 0
359 },
360 "users_default": 0
361 },
362 "event_id": "$15139375512JaHAW:localhost",
363 "origin_server_ts": 151393755,
364 "sender": "@example:localhost",
365 "state_key": "",
366 "type": "m.room.power_levels",
367 "unsigned": {
368 "age": 703422
369 }
370 })
371});
372
373pub static PRESENCE: Lazy<JsonValue> = Lazy::new(|| {
374 json!({
375 "content": {
376 "avatar_url": "mxc://localhost/wefuiwegh8742w",
377 "currently_active": false,
378 "last_active_ago": 1,
379 "presence": "online",
380 "status_msg": "Making cupcakes"
381 },
382 "sender": "@example:localhost",
383 "type": "m.presence"
384 })
385});
386
387pub static PUSH_RULES: Lazy<JsonValue> = Lazy::new(|| {
388 json!({
389 "content": {
390 "global": {
391 "content": [
392 {
393 "actions": [
394 "notify",
395 {
396 "set_tweak": "sound",
397 "value": "default"
398 },
399 {
400 "set_tweak": "highlight"
401 }
402 ],
403 "default": true,
404 "enabled": true,
405 "pattern": "example",
406 "rule_id": ".m.rule.contains_user_name"
407 }
408 ],
409 "override": [
410 {
411 "actions": [
412 "dont_notify"
413 ],
414 "conditions": [],
415 "default": true,
416 "enabled": false,
417 "rule_id": ".m.rule.master"
418 },
419 {
420 "actions": [
421 "dont_notify"
422 ],
423 "conditions": [
424 {
425 "key": "content.msgtype",
426 "kind": "event_match",
427 "pattern": "m.notice"
428 }
429 ],
430 "default": true,
431 "enabled": true,
432 "rule_id": ".m.rule.suppress_notices"
433 }
434 ],
435 "room": [
436 {
437 "actions": [
438 "notify",
439 {
440 "set_tweak": "sound",
441 "value": "default"
442 }
443 ],
444 "rule_id": *DEFAULT_TEST_ROOM_ID,
445 "default": false,
446 "enabled": true
447 }
448 ],
449 "sender": [],
450 "underride": [
451 {
452 "actions": [
453 "notify",
454 {
455 "set_tweak": "sound",
456 "value": "ring"
457 },
458 {
459 "set_tweak": "highlight",
460 "value": false
461 }
462 ],
463 "conditions": [
464 {
465 "key": "type",
466 "kind": "event_match",
467 "pattern": "m.call.invite"
468 }
469 ],
470 "default": true,
471 "enabled": true,
472 "rule_id": ".m.rule.call"
473 },
474 {
475 "actions": [
476 "notify",
477 {
478 "set_tweak": "sound",
479 "value": "default"
480 },
481 {
482 "set_tweak": "highlight"
483 }
484 ],
485 "conditions": [
486 {
487 "kind": "contains_display_name"
488 }
489 ],
490 "default": true,
491 "enabled": true,
492 "rule_id": ".m.rule.contains_display_name"
493 },
494 {
495 "actions": [
496 "notify",
497 {
498 "set_tweak": "sound",
499 "value": "default"
500 },
501 {
502 "set_tweak": "highlight",
503 "value": false
504 }
505 ],
506 "conditions": [
507 {
508 "is": "2",
509 "kind": "room_member_count"
510 },
511 {
512 "key": "type",
513 "kind": "event_match",
514 "pattern": "m.room.message"
515 }
516 ],
517 "default": true,
518 "enabled": true,
519 "rule_id": ".m.rule.room_one_to_one"
520 },
521 {
522 "actions": [
523 "notify",
524 {
525 "set_tweak": "sound",
526 "value": "default"
527 },
528 {
529 "set_tweak": "highlight",
530 "value": false
531 }
532 ],
533 "conditions": [
534 {
535 "key": "type",
536 "kind": "event_match",
537 "pattern": "m.room.member"
538 },
539 {
540 "key": "content.membership",
541 "kind": "event_match",
542 "pattern": "invite"
543 },
544 {
545 "key": "state_key",
546 "kind": "event_match",
547 "pattern": "@example:localhost"
548 }
549 ],
550 "default": true,
551 "enabled": true,
552 "rule_id": ".m.rule.invite_for_me"
553 },
554 {
555 "actions": [
556 "notify",
557 {
558 "set_tweak": "highlight",
559 "value": false
560 }
561 ],
562 "conditions": [
563 {
564 "key": "type",
565 "kind": "event_match",
566 "pattern": "m.room.member"
567 }
568 ],
569 "default": true,
570 "enabled": true,
571 "rule_id": ".m.rule.member_event"
572 },
573 {
574 "actions": [
575 "notify",
576 {
577 "set_tweak": "highlight",
578 "value": false
579 }
580 ],
581 "conditions": [
582 {
583 "key": "type",
584 "kind": "event_match",
585 "pattern": "m.room.message"
586 }
587 ],
588 "default": true,
589 "enabled": true,
590 "rule_id": ".m.rule.message"
591 }
592 ]
593 }
594 },
595 "type": "m.push_rules"
596 })
597});
598
599pub static READ_RECEIPT: Lazy<JsonValue> = Lazy::new(|| {
600 json!({
601 "content": {
602 "$example": {
603 "m.read": {
604 "@example:localhost": {
605 "ts": 1436451550
606 }
607 }
608 }
609 },
610 "room_id": "!test:localhost",
611 "type": "m.receipt"
612 })
613});
614
615pub static READ_RECEIPT_OTHER: Lazy<JsonValue> = Lazy::new(|| {
616 json!({
617 "content": {
618 "$other": {
619 "m.read": {
620 "@example:localhost": {
621 "ts": 1436964550
622 }
623 }
624 }
625 },
626 "room_id": "!test:localhost",
627 "type": "m.receipt"
628 })
629});
630
631pub static REDACTED_INVALID: Lazy<JsonValue> = Lazy::new(|| {
632 json!({
633 "content": {},
634 "event_id": "$15275046980maRLj:localhost",
635 "origin_server_ts": 1527504698,
636 "sender": "@example:localhost",
637 "type": "m.room.message"
638 })
639});
640
641pub static REDACTED_STATE: Lazy<JsonValue> = Lazy::new(|| {
642 json!({
643 "content": {},
644 "event_id": "$example_id:example.org",
645 "origin_server_ts": 153232493,
646 "sender": "@example:example.org",
647 "state_key": "test_state_key",
648 "type": "m.some.state",
649 "unsigned": {
650 "age": 3069315,
651 "redacted_because": {
652 "content": {},
653 "event_id": "$redaction_example_id:example.org",
654 "origin_server_ts": 153232494,
655 "redacts": "$example_id:example.org",
656 "sender": "@example:example:org",
657 "type": "m.room.redaction",
658 "unsigned": {"age": 30693147}
659 },
660 "redacted_by": "$redaction_example_id:example.org"
661 }
662 })
663});
664
665pub static ROOM_AVATAR: Lazy<JsonValue> = Lazy::new(|| {
666 json!({
667 "content": {
668 "info": {
669 "h": 398,
670 "mimetype": "image/jpeg",
671 "size": 31037,
672 "w": 394
673 },
674 "url": "mxc://domain.com/JWEIFJgwEIhweiWJE"
675 },
676 "event_id": "$143273582443PhrSn:domain.com",
677 "origin_server_ts": 143273582,
678 "room_id": "!jEsUZKDJdhlrceRyVU:domain.com",
679 "sender": "@example:domain.com",
680 "state_key": "",
681 "type": "m.room.avatar",
682 "unsigned": {
683 "age": 1234
684 }
685 })
686});
687
688pub static TAG: Lazy<JsonValue> = Lazy::new(|| {
689 json!({
690 "content": {
691 "tags": {
692 "m.favourite": {
693 "order": 0.0
694 },
695 "u.work": {
696 "order": 0.9
697 }
698 }
699 },
700 "type": "m.tag"
701 })
702});
703
704pub static TOPIC: Lazy<JsonValue> = Lazy::new(|| {
706 json!({
707 "content": {
708 "topic": "😀"
709 },
710 "event_id": "$151957878228ssqrJ:localhost",
711 "origin_server_ts": 151957878,
712 "sender": "@example:localhost",
713 "state_key": "",
714 "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
715 "type": "m.room.topic",
716 "prev_content": {
717 "topic": "test"
718 },
719 "unsigned": {
720 "age": 1392989,
721 "prev_sender": "@example:localhost",
722 "replaces_state": "$151957069225EVYKm:localhost"
723 }
724 })
725});
726
727pub static TYPING: Lazy<JsonValue> = Lazy::new(|| {
728 json!({
729 "content": {
730 "user_ids": [
731 "@alice:matrix.org",
732 "@bob:example.com"
733 ]
734 },
735 "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
736 "type": "m.typing"
737 })
738});
739
740pub static TOPIC_REDACTION: Lazy<JsonValue> = Lazy::new(|| {
741 json!({
742 "content": {},
743 "redacts": "$151957878228ssqrJ:localhost",
744 "event_id": "$151957878228ssqrJ_REDACTION:localhost",
745 "origin_server_ts": 151957879,
746 "sender": "@example:localhost",
747 "type": "m.room.redaction",
748 "unsigned": {
749 "age": 1392990,
750 "prev_sender": "@example:localhost",
751 }
752 })
753});