Compare commits

..
Author SHA1 Message Date
0c660a98a7
just grab events out of get_mentions for now 2026-09-22 09:57:10 -04:00
09534a6775
use GomuksConfig 2026-09-22 09:53:00 -04:00
4 changed files with 70 additions and 12 deletions

3
.gitmodules vendored
View file

@ -1,4 +1,3 @@
[submodule "gomuks"]
path = gomuks
url = https://github.com/Henry-Hiles/gomuks
branch = quad/feat/customizable-device-name
url = https://github.com/gomuks/gomuks

2
gomuks

@ -1 +1 @@
Subproject commit ae11daa1b14b103688e57accb9c65ad6401cb3ef
Subproject commit b11eedca121a7081d3ee48165ba363e722d18d87

View file

@ -20,6 +20,7 @@ import "package:nexus/main.dart";
import "package:nexus/models/capabilities.dart";
import "package:nexus/models/content/message.dart";
import "package:nexus/models/event.dart";
import "package:nexus/models/gomuks_config.dart";
import "package:nexus/models/oauth_auth_code_response.dart";
import "package:nexus/models/open_graph_data.dart";
import "package:nexus/models/paginate.dart";
@ -70,14 +71,17 @@ class ClientController extends AsyncNotifier<int> {
}
}
final handle = await Isolate.run(() {
final message =
"Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}"
.toNativeUtf8()
.cast<Char>();
final bufferPointer = GomuksConfig(
matrix: .new(
initialDeviceDisplayName:
"Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}",
),
).toJson().toGomuksBufferPtr();
try {
return GomuksInit(message);
return GomuksInit(bufferPointer.ref);
} finally {
calloc.free(message);
calloc.free(bufferPointer);
}
});
@ -292,9 +296,9 @@ class ClientController extends AsyncNotifier<int> {
}
Future<IList<Event>> getMentions(GetMentionsRequest request) async => .new(
((await _sendCommand("get_mentions", request.toJson())) as List).map(
(event) => .fromJson(event),
),
// TODO: Handle `related_events`
((await _sendCommand("get_mentions", request.toJson()))["events"] as List)
.map((event) => .fromJson(event)),
);
Future<Event?> getEvent(GetEventRequest request) async {

View file

@ -0,0 +1,55 @@
import "package:freezed_annotation/freezed_annotation.dart";
part "gomuks_config.freezed.dart";
part "gomuks_config.g.dart";
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const GomuksConfig({
final MatrixConfig? matrix,
final PushConfig? push,
final MediaConfig? media,
}) with _$GomuksConfig {
Map<String, Object?> toJson() => _$GomuksConfigToJson(this);
factory GomuksConfig.fromJson(Map<String, Object?> json) =>
_$GomuksConfigFromJson(json);
}
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const MatrixConfig({
@JsonKey(name: "disable_http2") final bool disableHttp2 = false,
@JsonKey(name: "set_presence") final String? setPresence,
@JsonKey(name: "initial_device_display_name")
required final String initialDeviceDisplayName,
}) with _$MatrixConfig {
Map<String, Object?> toJson() => _$MatrixConfigToJson(this);
factory MatrixConfig.fromJson(Map<String, Object?> json) =>
_$MatrixConfigFromJson(json);
}
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const PushConfig({
@JsonKey(name: "fcm_gateway") required final String fcmGateway,
@JsonKey(name: "vapid_private_key") required final String vapidPrivateKey,
@JsonKey(name: "vapid_public_key") required final String vapidPublicKey,
}) with _$PushConfig {
Map<String, Object?> toJson() => _$PushConfigToJson(this);
factory PushConfig.fromJson(Map<String, Object?> json) =>
_$PushConfigFromJson(json);
}
@Freezed(toJson: false, fromJson: false)
@JsonSerializable()
class const MediaConfig({
@JsonKey(name: "thumbnail_size") required final int thumbnailSize,
}) with _$MediaConfig {
Map<String, Object?> toJson() => _$MediaConfigToJson(this);
factory MediaConfig.fromJson(Map<String, Object?> json) =>
_$MediaConfigFromJson(json);
}