@@ -2,31 +2,44 @@ import 'package:json_annotation/json_annotation.dart';
2
2
3
3
part 'submessage.g.dart' ;
4
4
5
- /// Data used for certain experimental Zulip widgets including polls and todo
6
- /// lists.
5
+ /// Data used for Zulip "widgets" within messages, like polls and todo lists.
7
6
///
8
- /// See :
9
- /// https://zulip.com/api/get-messages#response
7
+ /// For docs, see :
8
+ /// https://zulip.com/api/get-messages#response (search for "submessage")
10
9
/// https://zulip.readthedocs.io/en/latest/subsystems/widgets.html
10
+ ///
11
+ /// This is an underdocumented part of the Zulip Server API.
12
+ /// So in addition to docs, see other clients:
13
+ /// https://github.com/zulip/zulip-mobile/blob/2217c858e/src/api/modelTypes.js#L800-L861
14
+ /// https://github.com/zulip/zulip-mobile/blob/2217c858e/src/webview/html/message.js#L118-L192
15
+ /// https://github.com/zulip/zulip/blob/40f59a05c/web/src/submessage.ts
16
+ /// https://github.com/zulip/zulip/blob/40f59a05c/web/shared/src/poll_data.ts
11
17
@JsonSerializable (fieldRename: FieldRename .snake)
12
18
class Submessage {
13
19
const Submessage ({
20
+ required this .senderId,
14
21
required this .msgType,
15
22
required this .content,
16
- required this .senderId,
17
23
});
18
24
25
+ // TODO(server): should we be sorting a message's submessages by ID? Web seems to:
26
+ // https://github.com/zulip/zulip/blob/40f59a05c55e0e4f26ca87d2bca646770e94bff0/web/src/submessage.ts#L88
27
+ // final int id; // ignored because we don't use it
28
+
29
+ /// The sender of this submessage (not necessarily of the [Message] it's on).
30
+ final int senderId;
31
+
32
+ // final int messageId; // ignored; redundant with [Message.id]
33
+
19
34
@JsonKey (unknownEnumValue: SubmessageType .unknown)
20
35
final SubmessageType msgType;
21
- /// [SubmessageData] encoded in JSON.
36
+
37
+ /// A JSON encoding of a [SubmessageData] .
22
38
// We cannot parse the String into one of the [SubmessageData] classes because
23
39
// information from other submessages are required. Specifically, we need:
24
40
// * the index of this submessage in [Message.submessages];
25
41
// * the [WidgetType] of the first [Message.submessages].
26
42
final String content;
27
- // final int messageId; // ignored; redundant with [Message.id]
28
- final int senderId;
29
- // final int id; // ignored because it is unused
30
43
31
44
factory Submessage .fromJson (Map <String , Object ?> json) =>
32
45
_$SubmessageFromJson (json);
@@ -35,6 +48,10 @@ class Submessage {
35
48
}
36
49
37
50
/// As in [Submessage.msgType] .
51
+ ///
52
+ /// The only type of submessage that actually exists in Zulip (as of 2024,
53
+ /// and since this "submessages" subsystem was created in 2017–2018)
54
+ /// is [SubmessageType.widget] .
38
55
enum SubmessageType {
39
56
widget,
40
57
unknown,
0 commit comments