Skip to main content

matrix_sdk_test/test_json/
sync.rs

1//! Complete sync responses.
2
3use std::sync::LazyLock;
4
5use serde_json::{Value as JsonValue, json};
6
7use crate::DEFAULT_TEST_ROOM_ID;
8
9pub static SYNC: LazyLock<JsonValue> = LazyLock::new(|| {
10    json!({
11        "device_one_time_keys_count": {},
12        "next_batch": "s526_47314_0_7_1_1_1_11444_1",
13        "device_lists": {
14            "changed": [
15                "@example:example.org"
16            ],
17            "left": []
18        },
19        "account_data": {
20            "events": [
21                {
22                    "content": {
23                        "ignored_users": {
24                            "@someone:example.org": {}
25                        }
26                    },
27                    "type": "m.ignored_user_list"
28                }
29            ]
30        },
31        "rooms": {
32            "invite": {},
33            "join": {
34                *DEFAULT_TEST_ROOM_ID: {
35                    "summary": {},
36                    "account_data": {
37                        "events": [
38                            {
39                                "content": {
40                                    "event_id": "$someplace:example.org"
41                                },
42                                "room_id": "!roomid:room.com",
43                                "type": "m.fully_read"
44                            }
45                        ]
46                    },
47                    "ephemeral": {
48                        "events": [
49                            {
50                                "content": {
51                                    "$151680659217152dPKjd:localhost": {
52                                        "m.read": {
53                                            "@example:localhost": {
54                                                "ts": 151680989
55                                            }
56                                        }
57                                    }
58                                },
59                                "room_id": *DEFAULT_TEST_ROOM_ID,
60                                "type": "m.receipt"
61                            },
62                        ]
63                    },
64                    "state": {
65                        "events": [
66                            {
67                                "content": {
68                                    "join_rule": "public"
69                                },
70                                "event_id": "$15139375514WsgmR:localhost",
71                                "origin_server_ts": 1784626598,
72                                "sender": "@example:localhost",
73                                "state_key": "",
74                                "type": "m.room.join_rules",
75                                "unsigned": {
76                                    "age": 7034220
77                                }
78                            },
79                            {
80                                "content": {
81                                    "avatar_url": null,
82                                    "displayname": "example",
83                                    "membership": "join"
84                                },
85                                "event_id": "$151800140517rfvjc:localhost",
86                                "membership": "join",
87                                "origin_server_ts": 1784626598,
88                                "sender": "@example:localhost",
89                                "state_key": "@example:localhost",
90                                "type": "m.room.member",
91                                "unsigned": {
92                                    "age": 2970366,
93                                    "replaces_state": "$151800111315tsynI:localhost"
94                                }
95                            },
96                            {
97                                "content": {
98                                    "history_visibility": "shared"
99                                },
100                                "event_id": "$15139375515VaJEY:localhost",
101                                "origin_server_ts": 1784626598,
102                                "sender": "@example:localhost",
103                                "state_key": "",
104                                "type": "m.room.history_visibility",
105                                "unsigned": {
106                                    "age": 7034220
107                                }
108                            },
109                            {
110                                "content": {
111                                    "creator": "@example:localhost"
112                                },
113                                "event_id": "$15139375510KUZHi:localhost",
114                                "origin_server_ts": 1784626598,
115                                "sender": "@example:localhost",
116                                "state_key": "",
117                                "type": "m.room.create",
118                                "unsigned": {
119                                    "age": 703422
120                                }
121                            },
122                            {
123                                "content": {
124                                    "aliases": [
125                                        "#tutorial:localhost"
126                                    ]
127                                },
128                                "event_id": "$15139375516NUgtD:localhost",
129                                "origin_server_ts": 1784626598,
130                                "sender": "@example:localhost",
131                                "state_key": "localhost",
132                                "type": "m.room.aliases",
133                                "unsigned": {
134                                    "age": 703422
135                                }
136                            },
137                            {
138                                "content": {
139                                    "topic": "room topic"
140                                },
141                                "event_id": "$151957878228ssqrJ:localhost",
142                                "origin_server_ts": 1784626598,
143                                "sender": "@example:localhost",
144                                "state_key": "",
145                                "type": "m.room.topic",
146                                "unsigned": {
147                                    "age": 1392989709,
148                                    "prev_content": {
149                                        "topic": "test"
150                                    },
151                                    "prev_sender": "@example:localhost",
152                                    "replaces_state": "$151957069225EVYKm:localhost"
153                                }
154                            },
155                            {
156                                "content": {
157                                    "ban": 50,
158                                    "events": {
159                                        "m.room.avatar": 50,
160                                        "m.room.canonical_alias": 50,
161                                        "m.room.history_visibility": 100,
162                                        "m.room.name": 50,
163                                        "m.room.power_levels": 100
164                                    },
165                                    "events_default": 0,
166                                    "invite": 0,
167                                    "kick": 50,
168                                    "redact": 50,
169                                    "state_default": 50,
170                                    "users": {
171                                        "@example:localhost": 100
172                                    },
173                                    "users_default": 0
174                                },
175                                "event_id": "$15139375512JaHAW:localhost",
176                                "origin_server_ts": 1784626598,
177                                "sender": "@example:localhost",
178                                "state_key": "",
179                                "type": "m.room.power_levels",
180                                "unsigned": {
181                                    "age": 703422
182                                }
183                            },
184                            {
185                                "content": {
186                                    "alias": "#tutorial:localhost"
187                                },
188                                "event_id": "$15139375513VdeRF:localhost",
189                                "origin_server_ts": 1784626598,
190                                "sender": "@example:localhost",
191                                "state_key": "",
192                                "type": "m.room.canonical_alias",
193                                "unsigned": {
194                                    "age": 703422
195                                }
196                            },
197                            {
198                                "content": {
199                                    "avatar_url": null,
200                                    "displayname": "example2",
201                                    "membership": "join"
202                                },
203                                "event_id": "$152034824468gOeNB:localhost",
204                                "membership": "join",
205                                "origin_server_ts": 1784626598,
206                                "sender": "@example2:localhost",
207                                "state_key": "@example2:localhost",
208                                "type": "m.room.member",
209                                "unsigned": {
210                                    "age": 623527289,
211                                    "prev_content": {
212                                        "membership": "leave"
213                                    },
214                                    "prev_sender": "@example:localhost",
215                                    "replaces_state": "$152034819067QWJxM:localhost"
216                                }
217                            },
218                        ]
219                    },
220                    "timeline": {
221                        "events": [
222                            {
223                                "content": {
224                                    "body": "baba",
225                                    "format": "org.matrix.custom.html",
226                                    "formatted_body": "<strong>baba</strong>",
227                                    "msgtype": "m.text"
228                                },
229                                "event_id": "$152037280074GZeOm:localhost",
230                                "origin_server_ts": 1784626598,
231                                "sender": "@example:localhost",
232                                "type": "m.room.message",
233                                "unsigned": {
234                                    "age": 598971425
235                                }
236                            }
237                        ],
238                        "limited": true,
239                        "prev_batch": "t392-516_47314_0_7_1_1_1_11444_1"
240                    },
241                    "unread_notifications": {
242                        "highlight_count": 0,
243                        "notification_count": 11
244                    }
245                }
246            },
247            "leave": {}
248        },
249        "to_device": {
250            "events": []
251        },
252        "presence": {
253            "events": [
254                {
255                    "content": {
256                        "avatar_url": "mxc://localhost/wefuiwegh8742w",
257                        "currently_active": false,
258                        "last_active_ago": 1,
259                        "presence": "online",
260                        "status_msg": "Making cupcakes"
261                    },
262                    "sender": "@example:localhost",
263                    "type": "m.presence"
264                }
265            ]
266        }
267    })
268});
269
270pub static DEFAULT_SYNC_SUMMARY: LazyLock<JsonValue> = LazyLock::new(|| {
271    json!({
272        "device_one_time_keys_count": {},
273        "next_batch": "s526_47314_0_7_1_1_1_11444_1",
274        "device_lists": {
275            "changed": [
276                "@example:example.org"
277            ],
278            "left": []
279        },
280        "rooms": {
281            "invite": {},
282            "join": {
283                *DEFAULT_TEST_ROOM_ID: {
284                    "summary": {
285                        "m.heroes": [
286                          "@example2:localhost"
287                        ],
288                        "m.joined_member_count": 2,
289                        "m.invited_member_count": 0
290                      },
291                    "account_data": {
292                        "events": [
293                            {
294                                "content": {
295                                    "ignored_users": {
296                                        "@someone:example.org": {}
297                                    }
298                                },
299                                "type": "m.ignored_user_list"
300                            }
301                        ]
302                    },
303                    "ephemeral": {
304                        "events": [
305                            {
306                                "content": {
307                                    "$151680659217152dPKjd:localhost": {
308                                        "m.read": {
309                                            "@example:localhost": {
310                                                "ts": 151680989
311                                            }
312                                        }
313                                    }
314                                },
315                                "type": "m.receipt"
316                            },
317                            {
318                                "content": {
319                                    "event_id": "$someplace:example.org"
320                                },
321                                "room_id": "!roomid:room.com",
322                                "type": "m.fully_read"
323                            }
324                        ]
325                    },
326                    "state": {
327                        "events": [
328                            {
329                                "content": {
330                                    "join_rule": "public"
331                                },
332                                "event_id": "$15139375514WsgmR:localhost",
333                                "origin_server_ts": 1784626598,
334                                "sender": "@example:localhost",
335                                "state_key": "",
336                                "type": "m.room.join_rules",
337                                "unsigned": {
338                                    "age": 7034220
339                                }
340                            },
341                            {
342                                "content": {
343                                    "avatar_url": null,
344                                    "displayname": "example",
345                                    "membership": "join"
346                                },
347                                "event_id": "$151800140517rfvjc:localhost",
348                                "membership": "join",
349                                "origin_server_ts": 1784626598,
350                                "sender": "@example:localhost",
351                                "state_key": "@example:localhost",
352                                "type": "m.room.member",
353                                "unsigned": {
354                                    "age": 297036,
355                                    "replaces_state": "$151800111315tsynI:localhost"
356                                }
357                            },
358                            {
359                                "content": {
360                                    "history_visibility": "shared"
361                                },
362                                "event_id": "$15139375515VaJEY:localhost",
363                                "origin_server_ts": 1784626598,
364                                "sender": "@example:localhost",
365                                "state_key": "",
366                                "type": "m.room.history_visibility",
367                                "unsigned": {
368                                    "age": 703422
369                                }
370                            },
371                            {
372                                "content": {
373                                    "creator": "@example:localhost"
374                                },
375                                "event_id": "$15139375510KUZHi:localhost",
376                                "origin_server_ts": 1784626598,
377                                "sender": "@example:localhost",
378                                "state_key": "",
379                                "type": "m.room.create",
380                                "unsigned": {
381                                    "age": 703422
382                                }
383                            },
384                            {
385                                "content": {
386                                    "topic": "room topic"
387                                },
388                                "event_id": "$151957878228ssqrJ:localhost",
389                                "origin_server_ts": 1784626598,
390                                "sender": "@example:localhost",
391                                "state_key": "",
392                                "type": "m.room.topic",
393                                "unsigned": {
394                                    "age": 1392989709,
395                                    "prev_content": {
396                                        "topic": "test"
397                                    },
398                                    "prev_sender": "@example:localhost",
399                                    "replaces_state": "$151957069225EVYKm:localhost"
400                                }
401                            },
402                            {
403                                "content": {
404                                    "ban": 50,
405                                    "events": {
406                                        "m.room.avatar": 50,
407                                        "m.room.canonical_alias": 50,
408                                        "m.room.history_visibility": 100,
409                                        "m.room.name": 50,
410                                        "m.room.power_levels": 100
411                                    },
412                                    "events_default": 0,
413                                    "invite": 0,
414                                    "kick": 50,
415                                    "redact": 50,
416                                    "state_default": 50,
417                                    "users": {
418                                        "@example:localhost": 100
419                                    },
420                                    "users_default": 0
421                                },
422                                "event_id": "$15139375512JaHAW:localhost",
423                                "origin_server_ts": 1784626598,
424                                "sender": "@example:localhost",
425                                "state_key": "",
426                                "type": "m.room.power_levels",
427                                "unsigned": {
428                                    "age": 703422
429                                }
430                            },
431                            {
432                                "content": {
433                                    "avatar_url": null,
434                                    "displayname": "example2",
435                                    "membership": "join"
436                                },
437                                "event_id": "$152034824468gOeNB:localhost",
438                                "membership": "join",
439                                "origin_server_ts": 1784626598,
440                                "sender": "@example2:localhost",
441                                "state_key": "@example2:localhost",
442                                "type": "m.room.member",
443                                "unsigned": {
444                                    "age": 623527289,
445                                    "prev_content": {
446                                        "membership": "leave"
447                                    },
448                                    "prev_sender": "@example:localhost",
449                                    "replaces_state": "$152034819067QWJxM:localhost"
450                                }
451                            },
452                            {
453                                "content": {
454                                  "membership": "leave",
455                                  "reason": "offline",
456                                  "avatar_url": "avatar.com",
457                                  "displayname": "example"
458                                },
459                                "event_id": "$1585345508297748AIUBh:matrix.org",
460                                "origin_server_ts": 1784626598,
461                                "sender": "@example:localhost",
462                                "state_key": "@example:localhost",
463                                "type": "m.room.member",
464                                "unsigned": {
465                                  "replaces_state": "$1585345354296486IGZfp:localhost",
466                                  "prev_content": {
467                                    "avatar_url": "avatar.com",
468                                    "displayname": "example",
469                                    "membership": "join"
470                                  },
471                                  "prev_sender": "@example2:localhost",
472                                  "age": 6992
473                                },
474                                "room_id": "!roomid:room.com"
475                              }
476                        ]
477                    },
478                    "timeline": {
479                        "events": [
480                            {
481                                "content": {
482                                    "body": "baba",
483                                    "format": "org.matrix.custom.html",
484                                    "formatted_body": "<strong>baba</strong>",
485                                    "msgtype": "m.text"
486                                },
487                                "event_id": "$152037280074GZeOm:localhost",
488                                "origin_server_ts": 1784626598,
489                                "sender": "@example:localhost",
490                                "type": "m.room.message",
491                                "unsigned": {
492                                    "age": 598971425
493                                }
494                            }
495                        ],
496                        "limited": true,
497                        "prev_batch": "t392-516_47314_0_7_1_1_1_11444_1"
498                    },
499                    "unread_notifications": {
500                        "highlight_count": 0,
501                        "notification_count": 11
502                    }
503                }
504            },
505            "leave": {}
506        },
507        "to_device": {
508            "events": []
509        },
510        "presence": {
511            "events": [
512                {
513                    "content": {
514                        "avatar_url": "mxc://localhost/wefuiwegh8742w",
515                        "currently_active": false,
516                        "last_active_ago": 1,
517                        "presence": "online",
518                        "status_msg": "Making cupcakes"
519                    },
520                    "sender": "@example:localhost",
521                    "type": "m.presence"
522                }
523            ]
524        }
525    })
526});
527
528pub static INVITE_SYNC: LazyLock<JsonValue> = LazyLock::new(|| {
529    json!({
530        "device_one_time_keys_count": {},
531        "next_batch": "s526_47314_0_7_1_1_1_11444_2",
532        "device_lists": {
533            "changed": [
534                "@example:example.org"
535            ],
536            "left": []
537        },
538        "rooms": {
539            "invite": {
540                "!696r7674:example.com": {
541                  "invite_state": {
542                    "events": [
543                      {
544                        "sender": "@alice:example.com",
545                        "type": "m.room.name",
546                        "state_key": "",
547                        "content": {
548                          "name": "My Room Name"
549                        }
550                      },
551                      {
552                        "sender": "@alice:example.com",
553                        "type": "m.room.member",
554                        "state_key": "@bob:example.com",
555                        "content": {
556                          "membership": "invite"
557                        }
558                      }
559                    ]
560                  }
561                }
562              },
563            "join": {},
564            "leave": {}
565        },
566        "to_device": {
567            "events": []
568        },
569        "presence": {
570            "events": [
571                {
572                    "content": {
573                        "avatar_url": "mxc://localhost/wefuiwegh8742w",
574                        "currently_active": false,
575                        "last_active_ago": 1,
576                        "presence": "online",
577                        "status_msg": "Making cupcakes"
578                    },
579                    "sender": "@example:localhost",
580                    "type": "m.presence"
581                }
582            ]
583        }
584    })
585});
586
587pub static LEAVE_SYNC: LazyLock<JsonValue> = LazyLock::new(|| {
588    json!({
589        "device_one_time_keys_count": {},
590        "next_batch": "s526_47314_0_7_1_1_1_11444_1",
591        "device_lists": {
592            "changed": [
593                "@example:example.org"
594            ],
595            "left": []
596        },
597        "rooms": {
598            "invite": {},
599            "join": {},
600            "leave": {
601                *DEFAULT_TEST_ROOM_ID: {
602                    "summary": {},
603                    "account_data": {
604                        "events": []
605                    },
606                    "ephemeral": {
607                        "events": [
608                            {
609                                "content": {
610                                    "$151680659217152dPKjd:localhost": {
611                                        "m.read": {
612                                            "@example:localhost": {
613                                                "ts": 151680989
614                                            }
615                                        }
616                                    }
617                                },
618                                "type": "m.receipt"
619                            },
620                            {
621                                "content": {
622                                    "event_id": "$someplace:example.org"
623                                },
624                                "room_id": "!roomid:room.com",
625                                "type": "m.fully_read"
626                            }
627                        ]
628                    },
629                    "state": {
630                        "events": [
631                            {
632                                "content": {
633                                    "join_rule": "public"
634                                },
635                                "event_id": "$15139375514WsgmR:localhost",
636                                "origin_server_ts": 1784626598,
637                                "sender": "@example:localhost",
638                                "state_key": "",
639                                "type": "m.room.join_rules",
640                                "unsigned": {
641                                    "age": 703422
642                                }
643                            },
644                            {
645                                "content": {
646                                    "avatar_url": null,
647                                    "displayname": "example",
648                                    "membership": "join"
649                                },
650                                "event_id": "$151800140517rfvjc:localhost",
651                                "membership": "join",
652                                "origin_server_ts": 1784626598,
653                                "sender": "@example:localhost",
654                                "state_key": "@example:localhost",
655                                "type": "m.room.member",
656                                "unsigned": {
657                                    "age": 297036,
658                                    "replaces_state": "$151800111315tsynI:localhost"
659                                }
660                            },
661                            {
662                                "content": {
663                                    "history_visibility": "shared"
664                                },
665                                "event_id": "$15139375515VaJEY:localhost",
666                                "origin_server_ts": 1784626598,
667                                "sender": "@example:localhost",
668                                "state_key": "",
669                                "type": "m.room.history_visibility",
670                                "unsigned": {
671                                    "age": 703422
672                                }
673                            },
674                            {
675                                "content": {
676                                    "creator": "@example:localhost"
677                                },
678                                "event_id": "$15139375510KUZHi:localhost",
679                                "origin_server_ts": 1784626598,
680                                "sender": "@example:localhost",
681                                "state_key": "",
682                                "type": "m.room.create",
683                                "unsigned": {
684                                    "age": 703422
685                                }
686                            },
687                            {
688                                "content": {
689                                    "aliases": [
690                                        "#tutorial:localhost"
691                                    ]
692                                },
693                                "event_id": "$15139375516NUgtD:localhost",
694                                "origin_server_ts": 1784626598,
695                                "sender": "@example:localhost",
696                                "state_key": "localhost",
697                                "type": "m.room.aliases",
698                                "unsigned": {
699                                    "age": 703422
700                                }
701                            },
702                            {
703                                "content": {
704                                    "topic": "room topic"
705                                },
706                                "event_id": "$151957878228ssqrJ:localhost",
707                                "origin_server_ts": 1784626598,
708                                "sender": "@example:localhost",
709                                "state_key": "",
710                                "type": "m.room.topic",
711                                "unsigned": {
712                                    "age": 1392989709,
713                                    "prev_content": {
714                                        "topic": "test"
715                                    },
716                                    "prev_sender": "@example:localhost",
717                                    "replaces_state": "$151957069225EVYKm:localhost"
718                                }
719                            },
720                            {
721                                "content": {
722                                    "ban": 50,
723                                    "events": {
724                                        "m.room.avatar": 50,
725                                        "m.room.canonical_alias": 50,
726                                        "m.room.history_visibility": 100,
727                                        "m.room.name": 50,
728                                        "m.room.power_levels": 100
729                                    },
730                                    "events_default": 0,
731                                    "invite": 0,
732                                    "kick": 50,
733                                    "redact": 50,
734                                    "state_default": 50,
735                                    "users": {
736                                        "@example:localhost": 100
737                                    },
738                                    "users_default": 0
739                                },
740                                "event_id": "$15139375512JaHAW:localhost",
741                                "origin_server_ts": 1784626598,
742                                "sender": "@example:localhost",
743                                "state_key": "",
744                                "type": "m.room.power_levels",
745                                "unsigned": {
746                                    "age": 703422
747                                }
748                            },
749                            {
750                                "content": {
751                                    "alias": "#tutorial:localhost"
752                                },
753                                "event_id": "$15139375513VdeRF:localhost",
754                                "origin_server_ts": 1784626598,
755                                "sender": "@example:localhost",
756                                "state_key": "",
757                                "type": "m.room.canonical_alias",
758                                "unsigned": {
759                                    "age": 703422
760                                }
761                            },
762                            {
763                                "content": {
764                                    "avatar_url": null,
765                                    "displayname": "example2",
766                                    "membership": "join"
767                                },
768                                "event_id": "$152034824468gOeNB:localhost",
769                                "membership": "join",
770                                "origin_server_ts": 1784626598,
771                                "sender": "@example2:localhost",
772                                "state_key": "@example2:localhost",
773                                "type": "m.room.member",
774                                "unsigned": {
775                                    "age": 623527289,
776                                    "prev_content": {
777                                        "membership": "leave"
778                                    },
779                                    "prev_sender": "@example:localhost",
780                                    "replaces_state": "$152034819067QWJxM:localhost"
781                                }
782                            },
783                            {
784                                "content": {
785                                  "membership": "leave",
786                                  "reason": "offline",
787                                  "avatar_url": "mxc://avatar.com/ursn982srs2S",
788                                  "displayname": "example"
789                                },
790                                "event_id": "$1585345508297748AIUBh:matrix.org",
791                                "origin_server_ts": 1784626598,
792                                "sender": "@example:localhost",
793                                "state_key": "@example:localhost",
794                                "type": "m.room.member",
795                                "unsigned": {
796                                  "replaces_state": "$1585345354296486IGZfp:localhost",
797                                  "prev_content": {
798                                    "avatar_url": "mxc://avatar.com/ursn982srs2S",
799                                    "displayname": "example",
800                                    "membership": "join"
801                                  },
802                                  "prev_sender": "@example2:localhost",
803                                  "age": 6992
804                                },
805                                "room_id": "!roomid:room.com"
806                              }
807                        ]
808                    },
809                    "timeline": {
810                        "events": [
811                            {
812                                "content": {
813                                    "body": "baba",
814                                    "format": "org.matrix.custom.html",
815                                    "formatted_body": "<strong>baba</strong>",
816                                    "msgtype": "m.text"
817                                },
818                                "event_id": "$152037280074GZeOm:localhost",
819                                "origin_server_ts": 1784626598,
820                                "sender": "@example:localhost",
821                                "type": "m.room.message",
822                                "unsigned": {
823                                    "age": 598971425
824                                }
825                            }
826                        ],
827                        "limited": true,
828                        "prev_batch": "t392-516_47314_0_7_1_1_1_11444_1"
829                    },
830                    "unread_notifications": {
831                        "highlight_count": 0,
832                        "notification_count": 11
833                    }
834                }
835            }
836        },
837        "to_device": {
838            "events": []
839        },
840        "presence": {
841            "events": [
842                {
843                    "content": {
844                        "avatar_url": "mxc://localhost/wefuiwegh8742w",
845                        "currently_active": false,
846                        "last_active_ago": 1,
847                        "presence": "online",
848                        "status_msg": "Making cupcakes"
849                    },
850                    "sender": "@example:localhost",
851                    "type": "m.presence"
852                }
853            ]
854        }
855    })
856});