matrix_sdk_test/test_json/
sync_events.rs

1//! Discrete events found in a sync response.
2
3use once_cell::sync::Lazy;
4use serde_json::{Value as JsonValue, json};
5
6pub static ALIAS: Lazy<JsonValue> = Lazy::new(|| {
7    json!({
8        "content": {
9            "alias": "#tutorial:localhost"
10        },
11        "event_id": "$15139375513VdeRF:localhost",
12        "origin_server_ts": 151393755,
13        "sender": "@example:localhost",
14        "state_key": "",
15        "type": "m.room.canonical_alias",
16        "unsigned": {
17            "age": 703422
18        }
19    })
20});
21
22pub static ALIASES: Lazy<JsonValue> = Lazy::new(|| {
23    json!({
24        "content": {
25            "aliases": [
26                "#tutorial:localhost"
27            ]
28        },
29        "event_id": "$15139375516NUgtD:localhost",
30        "origin_server_ts": 151393755,
31        "sender": "@example:localhost",
32        "state_key": "localhost",
33        "type": "m.room.aliases",
34        "unsigned": {
35            "age": 703422
36        }
37    })
38});
39
40pub static CREATE: Lazy<JsonValue> = Lazy::new(|| {
41    json!({
42        "content": {
43            "creator": "@example:localhost",
44            "m.federate": true,
45            "room_version": "1"
46        },
47        "event_id": "$151957878228ekrDs:localhost",
48        "origin_server_ts": 15195787,
49        "sender": "@example:localhost",
50        "state_key": "",
51        "type": "m.room.create",
52        "unsigned": {
53            "age": 139298
54        }
55    })
56});
57
58pub static FULLY_READ: Lazy<JsonValue> = Lazy::new(|| {
59    json!({
60        "content": {
61            "event_id": "$someplace:example.org"
62        },
63        "room_id": "!somewhere:example.org",
64        "type": "m.fully_read"
65    })
66});
67
68pub static HISTORY_VISIBILITY: Lazy<JsonValue> = Lazy::new(|| {
69    json!({
70        "content": {
71            "history_visibility": "world_readable"
72        },
73        "event_id": "$151957878235ricnD:localhost",
74        "origin_server_ts": 151957878,
75        "sender": "@example:localhost",
76        "state_key": "",
77        "type": "m.room.history_visibility",
78        "unsigned": {
79          "age": 1392989
80        }
81    })
82});
83
84pub static JOIN_RULES: Lazy<JsonValue> = Lazy::new(|| {
85    json!({
86        "content": {
87            "join_rule": "public"
88        },
89        "event_id": "$151957878231iejdB:localhost",
90        "origin_server_ts": 151957878,
91        "sender": "@example:localhost",
92        "state_key": "",
93        "type": "m.room.join_rules",
94        "unsigned": {
95          "age": 1392989
96        }
97    })
98});
99
100pub static ENCRYPTION_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
101    json!({
102        "algorithm": "m.megolm.v1.aes-sha2",
103        "rotation_period_ms": 604800000,
104        "rotation_period_msgs": 100
105    })
106});
107
108pub static ENCRYPTION: Lazy<JsonValue> = Lazy::new(|| {
109    json!({
110        "content": *ENCRYPTION_CONTENT,
111        "event_id": "$143273582443PhrSn:example.org",
112        "origin_server_ts": 1432735824653u64,
113        "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
114        "sender": "@example:example.org",
115        "state_key": "",
116        "type": "m.room.encryption",
117        "unsigned": {
118            "age": 1234
119        }
120    })
121});
122
123pub static ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
124    json!({
125        "algorithm": "m.megolm.v1.aes-sha2",
126        "rotation_period_ms": 604800000,
127        "rotation_period_msgs": 100,
128        "io.element.msc3414.encrypt_state_events": true
129    })
130});
131
132pub static ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS: Lazy<JsonValue> = Lazy::new(|| {
133    json!({
134        "content": *ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS_CONTENT,
135        "event_id": "$143273582443PhrSn:example.org",
136        "origin_server_ts": 1432735824653u64,
137        "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
138        "sender": "@example:example.org",
139        "state_key": "",
140        "type": "m.room.encryption",
141        "unsigned": {
142            "age": 1234
143        }
144    })
145});
146
147// TODO: Move `prev_content` into `unsigned` once ruma supports it
148pub static MEMBER: Lazy<JsonValue> = Lazy::new(|| {
149    json!({
150        "content": {
151            "avatar_url": null,
152            "displayname": "example",
153            "membership": "join"
154        },
155        "event_id": "$151800140517rfvjc:localhost",
156        "membership": "join",
157        "origin_server_ts": 151800140,
158        "sender": "@example:localhost",
159        "state_key": "@example:localhost",
160        "type": "m.room.member",
161        "prev_content": {
162            "avatar_url": null,
163            "displayname": "example",
164            "membership": "invite"
165        },
166        "unsigned": {
167            "age": 297036,
168            "replaces_state": "$151800111315tsynI:localhost"
169        }
170    })
171});
172
173// Make @invited:localhost a member (note the confusing name)
174pub static MEMBER_ADDITIONAL: Lazy<JsonValue> = Lazy::new(|| {
175    json!({
176        "content": {
177            "membership": "join",
178        },
179        "event_id": "$747273582443PhrSn:localhost",
180        "origin_server_ts": 1472735824,
181        "sender": "@example:localhost",
182        "state_key": "@invited:localhost",
183        "type": "m.room.member",
184        "unsigned": {
185            "age": 1234
186        }
187    })
188});
189
190// Make @invited:localhost leave the room (note the confusing name)
191pub static MEMBER_LEAVE: Lazy<JsonValue> = Lazy::new(|| {
192    json!({
193        "content": {
194            "membership": "leave",
195        },
196        "event_id": "$747273582443PhrS9:localhost",
197        "origin_server_ts": 1472735820,
198        "sender": "@example:localhost",
199        "state_key": "@invited:localhost",
200        "type": "m.room.member",
201        "unsigned": {
202            "age": 1234
203        }
204    })
205});
206
207pub static MEMBER_BAN: Lazy<JsonValue> = Lazy::new(|| {
208    json!({
209        "content": {
210            "avatar_url": null,
211            "displayname": "example",
212            "membership": "ban"
213        },
214        "event_id": "$151800140517rfvjc:localhost",
215        "origin_server_ts": 151800140,
216        "sender": "@example:localhost",
217        "state_key": "@banned:localhost",
218        "type": "m.room.member",
219    })
220});
221
222pub static MEMBER_INVITE: Lazy<JsonValue> = Lazy::new(|| {
223    json!({
224        "content": {
225            "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF",
226            "displayname": "example",
227            "membership": "invite",
228            "reason": "Looking for support"
229        },
230        "event_id": "$143273582443PhrSn:localhost",
231        "origin_server_ts": 1432735824,
232        "room_id": "!jEsUZKDJdhlrceRyVU:localhost",
233        "sender": "@example:localhost",
234        "state_key": "@invited:localhost",
235        "type": "m.room.member",
236        "unsigned": {
237            "age": 1234,
238            "invite_room_state": [
239                {
240                    "content": {
241                        "name": "Example Room"
242                    },
243                    "sender": "@example:localhost",
244                    "state_key": "",
245                    "type": "m.room.name"
246                },
247                {
248                    "content": {
249                        "join_rule": "invite"
250                    },
251                    "sender": "@example:localhost",
252                    "state_key": "",
253                    "type": "m.room.join_rules"
254                }
255            ]
256        }
257    })
258});
259
260// TODO: Move `prev_content` into `unsigned` once ruma supports it
261pub static MEMBER_NAME_CHANGE: Lazy<JsonValue> = Lazy::new(|| {
262    json!({
263        "content": {
264            "avatar_url": null,
265            "displayname": "changed",
266            "membership": "join"
267        },
268        "event_id": "$151800234427abgho:localhost",
269        "membership": "join",
270        "origin_server_ts": 151800152,
271        "sender": "@example:localhost",
272        "state_key": "@example:localhost",
273        "type": "m.room.member",
274        "prev_content": {
275            "avatar_url": null,
276            "displayname": "example",
277            "membership": "join"
278        },
279        "unsigned": {
280            "age": 297032,
281            "replaces_state": "$151800140517rfvjc:localhost"
282        }
283    })
284});
285
286pub static MEMBER_STRIPPED: Lazy<JsonValue> = Lazy::new(|| {
287    json!({
288        "content": {
289            "avatar_url": null,
290            "displayname": "example",
291            "membership": "join"
292        },
293        "sender": "@example:localhost",
294        "state_key": "@example:localhost",
295        "type": "m.room.member",
296    })
297});
298
299pub static NAME: Lazy<JsonValue> = Lazy::new(|| {
300    json!({
301        "content": {
302            "name": "room name"
303        },
304        "event_id": "$15139375513VdeRF:localhost",
305        "origin_server_ts": 151393755,
306        "sender": "@example:localhost",
307        "state_key": "",
308        "type": "m.room.name",
309        "unsigned": {
310            "age": 703422
311        }
312    })
313});
314
315pub static NAME_STRIPPED: Lazy<JsonValue> = Lazy::new(|| {
316    json!({
317        "content": {
318            "name": "room name"
319        },
320        "sender": "@example:localhost",
321        "state_key": "",
322        "type": "m.room.name",
323    })
324});
325
326pub static PINNED_EVENTS: Lazy<JsonValue> = Lazy::new(|| {
327    json!({
328        "content": {
329            "pinned": [ "$a", "$b" ]
330        },
331        "event_id": "$15139375513VdeRF:localhost",
332        "origin_server_ts": 151393755,
333        "sender": "@example:localhost",
334        "state_key": "",
335        "type": "m.room.pinned_events",
336        "unsigned": {
337            "age": 703422
338        }
339    })
340});
341
342pub static POWER_LEVELS: Lazy<JsonValue> = Lazy::new(|| {
343    json!({
344        "content": {
345            "ban": 50,
346            "events": {
347                "m.room.avatar": 50,
348                "m.room.canonical_alias": 50,
349                "m.room.history_visibility": 100,
350                "m.room.name": 50,
351                "m.room.power_levels": 100,
352                "m.room.message": 25
353            },
354            "events_default": 0,
355            "invite": 0,
356            "kick": 50,
357            "redact": 50,
358            "state_default": 50,
359            "notifications": {
360                "room": 0
361            },
362            "users": {
363                "@example:localhost": 100,
364                "@bob:localhost": 0
365            },
366            "users_default": 0
367        },
368        "event_id": "$15139375512JaHAW:localhost",
369        "origin_server_ts": 151393755,
370        "sender": "@example:localhost",
371        "state_key": "",
372        "type": "m.room.power_levels",
373        "unsigned": {
374            "age": 703422
375        }
376    })
377});
378
379pub static PRESENCE: Lazy<JsonValue> = Lazy::new(|| {
380    json!({
381        "content": {
382            "avatar_url": "mxc://localhost/wefuiwegh8742w",
383            "currently_active": false,
384            "last_active_ago": 1,
385            "presence": "online",
386            "status_msg": "Making cupcakes"
387        },
388        "sender": "@example:localhost",
389        "type": "m.presence"
390    })
391});
392
393pub static REDACTED_INVALID: Lazy<JsonValue> = Lazy::new(|| {
394    json!({
395        "content": {},
396        "event_id": "$15275046980maRLj:localhost",
397        "origin_server_ts": 1527504698,
398        "sender": "@example:localhost",
399        "type": "m.room.message"
400    })
401});
402
403pub static REDACTED_STATE: Lazy<JsonValue> = Lazy::new(|| {
404    json!({
405        "content": {},
406        "event_id": "$example_id:example.org",
407        "origin_server_ts": 153232493,
408        "sender": "@example:example.org",
409        "state_key": "test_state_key",
410        "type": "m.some.state",
411        "unsigned": {
412            "age": 3069315,
413            "redacted_because": {
414                "content": {},
415                "event_id": "$redaction_example_id:example.org",
416                "origin_server_ts": 153232494,
417                "redacts": "$example_id:example.org",
418                "sender": "@example:example:org",
419                "type": "m.room.redaction",
420                "unsigned": {"age": 30693147}
421            },
422            "redacted_by": "$redaction_example_id:example.org"
423        }
424    })
425});
426
427pub static ROOM_AVATAR: Lazy<JsonValue> = Lazy::new(|| {
428    json!({
429        "content": {
430            "info": {
431                "h": 398,
432                "mimetype": "image/jpeg",
433                "size": 31037,
434                "w": 394
435            },
436            "url": "mxc://domain.com/JWEIFJgwEIhweiWJE"
437        },
438        "event_id": "$143273582443PhrSn:domain.com",
439        "origin_server_ts": 143273582,
440        "room_id": "!jEsUZKDJdhlrceRyVU:domain.com",
441        "sender": "@example:domain.com",
442        "state_key": "",
443        "type": "m.room.avatar",
444        "unsigned": {
445            "age": 1234
446        }
447    })
448});
449
450pub static TAG: Lazy<JsonValue> = Lazy::new(|| {
451    json!({
452        "content": {
453            "tags": {
454                "m.favourite": {
455                    "order": 0.0
456                },
457                "u.work": {
458                    "order": 0.9
459                }
460            }
461        },
462        "type": "m.tag"
463    })
464});
465
466// TODO: Move `prev_content` into `unsigned` once ruma supports it
467pub static TOPIC: Lazy<JsonValue> = Lazy::new(|| {
468    json!({
469        "content": {
470            "topic": "😀"
471        },
472        "event_id": "$151957878228ssqrJ:localhost",
473        "origin_server_ts": 151957878,
474        "sender": "@example:localhost",
475        "state_key": "",
476        "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
477        "type": "m.room.topic",
478        "prev_content": {
479            "topic": "test"
480        },
481        "unsigned": {
482          "age": 1392989,
483          "prev_sender": "@example:localhost",
484          "replaces_state": "$151957069225EVYKm:localhost"
485        }
486    })
487});
488
489pub static TOPIC_REDACTION: Lazy<JsonValue> = Lazy::new(|| {
490    json!({
491        "content": {},
492        "redacts": "$151957878228ssqrJ:localhost",
493        "event_id": "$151957878228ssqrJ_REDACTION:localhost",
494        "origin_server_ts": 151957879,
495        "sender": "@example:localhost",
496        "type": "m.room.redaction",
497        "unsigned": {
498          "age": 1392990,
499          "prev_sender": "@example:localhost",
500        }
501    })
502});
503
504pub static MARKED_UNREAD: Lazy<JsonValue> = Lazy::new(|| {
505    json!({
506        "content": {
507            "unread": true,
508        },
509        "type": "m.marked_unread",
510    })
511});