parent
47645ea327
commit
7f7bdbf525
3 changed files with 1477 additions and 577 deletions
17
lib/models/requests/get_threads.dart
Normal file
17
lib/models/requests/get_threads.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "get_threads.freezed.dart";
|
||||
part "get_threads.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const GetThreadsRequest({
|
||||
required final String roomId,
|
||||
final String? since,
|
||||
final int limit = 20,
|
||||
}) with _$GetThreadsRequest {
|
||||
Map<String, Object?> toJson() => _$GetThreadsRequestToJson(this);
|
||||
|
||||
factory GetThreadsRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$GetThreadsRequestFromJson(json);
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ class const SendEventRequest({
|
|||
// Merged into the content by toJson, as gomuks doesn't take these
|
||||
@JsonKey(includeToJson: false) final String? relatesTo,
|
||||
@JsonKey(includeToJson: false) final String? relationType,
|
||||
@JsonKey(includeToJson: false) final String? replyTo,
|
||||
@JsonKey(includeToJson: false) final Relation? reply,
|
||||
@JsonKey(includeToJson: false) final Mentions? mentions,
|
||||
final bool synchronous = false,
|
||||
final bool disableEncryption = false,
|
||||
|
|
@ -27,14 +27,14 @@ class const SendEventRequest({
|
|||
"content": {
|
||||
...content,
|
||||
"m.mentions": ?mentions?.toJson(),
|
||||
if (relatesTo != null || replyTo != null)
|
||||
if (relatesTo != null || reply != null)
|
||||
"m.relates_to": {
|
||||
...((content["m.relates_to"] as Map<String, dynamic>?) ?? {}),
|
||||
if (relatesTo != null) ...{
|
||||
"event_id": relatesTo,
|
||||
"rel_type": relationType,
|
||||
},
|
||||
if (replyTo != null) "m.in_reply_to": {"event_id": replyTo},
|
||||
...?reply?.toJson(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,11 +38,18 @@ class const Mentions({
|
|||
class const Relation({
|
||||
required final String eventId,
|
||||
required final RelationType relationType,
|
||||
final String? threadRoot,
|
||||
final bool isFallingBack = false,
|
||||
}) with _$Relation {
|
||||
Map<String, dynamic> toJson() {
|
||||
switch (relationType) {
|
||||
case RelationType.reply:
|
||||
return {
|
||||
if (threadRoot != null) ...{
|
||||
"rel_type": "m.thread",
|
||||
"event_id": threadRoot,
|
||||
"is_falling_back": isFallingBack,
|
||||
},
|
||||
"m.in_reply_to": {"event_id": eventId},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue