Merge pull request #1999 from famedly/krille/remove-basic-room-event
refactor: Remove BasicRoomEvent type
This commit is contained in:
commit
928f6ba96f
|
|
@ -22,7 +22,7 @@ jobs:
|
|||
export HOMESERVER_IMPLEMENTATION=${{matrix.homeserver}}
|
||||
export HOMESERVER="localhost:80"
|
||||
scripts/integration-server-${{matrix.homeserver}}.sh 2>&1 > /dev/null &
|
||||
sudo apt-get update && sudo apt-get install --no-install-recommends --no-install-suggests -y libolm3 libssl3
|
||||
sudo apt-get update && sudo apt-get install --no-install-recommends --no-install-suggests -y libolm3 libssl3 sqlite3 libsqlite3-dev
|
||||
source scripts/integration-create-environment-variables.sh
|
||||
scripts/integration-prepare-homeserver.sh
|
||||
scripts/prepare.sh
|
||||
|
|
|
|||
|
|
@ -245,10 +245,9 @@ class FakeMatrixApi extends BaseClient {
|
|||
join: {
|
||||
roomId: JoinedRoomUpdate(
|
||||
accountData: [
|
||||
sdk.BasicRoomEvent(
|
||||
sdk.BasicEvent(
|
||||
content: decodeJson(data),
|
||||
type: type,
|
||||
roomId: roomId,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ export 'matrix_api_lite/model/auth/authentication_types.dart';
|
|||
export 'matrix_api_lite/model/auth/authentication_user_identifier.dart';
|
||||
export 'matrix_api_lite/model/basic_event.dart';
|
||||
export 'matrix_api_lite/model/basic_event_with_sender.dart';
|
||||
export 'matrix_api_lite/model/basic_room_event.dart';
|
||||
export 'matrix_api_lite/model/event_types.dart';
|
||||
export 'matrix_api_lite/model/events/forwarded_room_key_content.dart';
|
||||
export 'matrix_api_lite/model/events/image_pack_content.dart';
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import 'package:matrix/matrix_api_lite/model/basic_event.dart';
|
||||
|
||||
class BasicRoomEvent extends BasicEvent {
|
||||
String? roomId;
|
||||
|
||||
BasicRoomEvent({
|
||||
this.roomId,
|
||||
required super.content,
|
||||
required super.type,
|
||||
});
|
||||
|
||||
BasicRoomEvent.fromJson(super.json)
|
||||
: roomId = json['room_id'] as String?,
|
||||
super.fromJson();
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
if (roomId != null) data['room_id'] = roomId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -170,8 +170,8 @@ class JoinedRoomUpdate extends SyncRoomUpdate {
|
|||
RoomSummary? summary;
|
||||
List<MatrixEvent>? state;
|
||||
TimelineUpdate? timeline;
|
||||
List<BasicRoomEvent>? ephemeral;
|
||||
List<BasicRoomEvent>? accountData;
|
||||
List<BasicEvent>? ephemeral;
|
||||
List<BasicEvent>? accountData;
|
||||
UnreadNotificationCounts? unreadNotifications;
|
||||
|
||||
JoinedRoomUpdate({
|
||||
|
|
@ -192,11 +192,11 @@ class JoinedRoomUpdate extends SyncRoomUpdate {
|
|||
timeline = json.tryGetFromJson('timeline', TimelineUpdate.fromJson),
|
||||
ephemeral = json
|
||||
.tryGetMap<String, List<Object?>>('ephemeral')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
?.map((i) => BasicEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
accountData = json
|
||||
.tryGetMap<String, List<Object?>>('account_data')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
?.map((i) => BasicEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
unreadNotifications = json.tryGetFromJson(
|
||||
'unread_notifications',
|
||||
|
|
@ -280,7 +280,7 @@ class KnockRoomUpdate extends SyncRoomUpdate {
|
|||
class LeftRoomUpdate extends SyncRoomUpdate {
|
||||
List<MatrixEvent>? state;
|
||||
TimelineUpdate? timeline;
|
||||
List<BasicRoomEvent>? accountData;
|
||||
List<BasicEvent>? accountData;
|
||||
|
||||
LeftRoomUpdate({
|
||||
this.state,
|
||||
|
|
@ -296,7 +296,7 @@ class LeftRoomUpdate extends SyncRoomUpdate {
|
|||
timeline = json.tryGetFromJson('timeline', TimelineUpdate.fromJson),
|
||||
accountData = json
|
||||
.tryGetMap<String, List<Object?>>('account_data')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
?.map((i) => BasicEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList();
|
||||
|
||||
Map<String, Object?> toJson() {
|
||||
|
|
|
|||
|
|
@ -1200,7 +1200,7 @@ class Client extends MatrixApi {
|
|||
roomAccountData: roomUpdate.accountData
|
||||
?.asMap()
|
||||
.map((k, v) => MapEntry(v.type, v)) ??
|
||||
<String, BasicRoomEvent>{},
|
||||
<String, BasicEvent>{},
|
||||
);
|
||||
// Set membership of room to leave, in the case we got a left room passed, otherwise
|
||||
// the left room would have still membership join, which would be wrong for the setState later
|
||||
|
|
@ -2713,7 +2713,7 @@ class Client extends MatrixApi {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _handleEphemerals(Room room, List<BasicRoomEvent> events) async {
|
||||
Future<void> _handleEphemerals(Room room, List<BasicEvent> events) async {
|
||||
final List<ReceiptEventContent> receipts = [];
|
||||
|
||||
for (final event in events) {
|
||||
|
|
@ -2734,9 +2734,8 @@ class Client extends MatrixApi {
|
|||
await receiptStateContent.update(e, room);
|
||||
}
|
||||
|
||||
final event = BasicRoomEvent(
|
||||
final event = BasicEvent(
|
||||
type: LatestReceiptState.eventType,
|
||||
roomId: room.id,
|
||||
content: receiptStateContent.toJson(),
|
||||
);
|
||||
await database?.storeRoomAccountData(room.id, event);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ abstract class DatabaseApi {
|
|||
|
||||
Future storeAccountData(String type, Map<String, Object?> content);
|
||||
|
||||
Future storeRoomAccountData(String roomId, BasicRoomEvent event);
|
||||
Future storeRoomAccountData(String roomId, BasicEvent event);
|
||||
|
||||
Future<Map<String, DeviceKeysList>> getUserDeviceKeys(Client client);
|
||||
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ class HiveCollectionsDatabase extends DatabaseApi {
|
|||
|
||||
for (final data in roomAccountDataList) {
|
||||
if (data == null) continue;
|
||||
final event = BasicRoomEvent.fromJson(copyMap(data));
|
||||
final event = BasicEvent.fromJson(copyMap(data));
|
||||
room.roomAccountData[event.type] = event;
|
||||
}
|
||||
|
||||
|
|
@ -696,7 +696,7 @@ class HiveCollectionsDatabase extends DatabaseApi {
|
|||
final roomAccountDataRaws = await _roomAccountDataBox.getAllValues();
|
||||
for (final entry in roomAccountDataRaws.entries) {
|
||||
final keys = TupleKey.fromString(entry.key);
|
||||
final basicRoomEvent = BasicRoomEvent.fromJson(
|
||||
final basicRoomEvent = BasicEvent.fromJson(
|
||||
copyMap(entry.value),
|
||||
);
|
||||
final roomId = keys.parts.first;
|
||||
|
|
@ -1096,7 +1096,7 @@ class HiveCollectionsDatabase extends DatabaseApi {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> storeRoomAccountData(String roomId, BasicRoomEvent event) async {
|
||||
Future<void> storeRoomAccountData(String roomId, BasicEvent event) async {
|
||||
await _roomAccountDataBox.put(
|
||||
TupleKey(roomId, event.type).toString(),
|
||||
copyMap(event.toJson()),
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
|||
|
||||
for (final data in roomAccountDataList) {
|
||||
if (data == null) continue;
|
||||
final event = BasicRoomEvent.fromJson(copyMap(data));
|
||||
final event = BasicEvent.fromJson(copyMap(data));
|
||||
room.roomAccountData[event.type] = event;
|
||||
}
|
||||
|
||||
|
|
@ -683,7 +683,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
|||
final roomAccountDataRaws = await _roomAccountDataBox.getAllValues();
|
||||
for (final entry in roomAccountDataRaws.entries) {
|
||||
final keys = TupleKey.fromString(entry.key);
|
||||
final basicRoomEvent = BasicRoomEvent.fromJson(
|
||||
final basicRoomEvent = BasicEvent.fromJson(
|
||||
copyMap(entry.value),
|
||||
);
|
||||
final roomId = keys.parts.first;
|
||||
|
|
@ -1084,7 +1084,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> storeRoomAccountData(String roomId, BasicRoomEvent event) async {
|
||||
Future<void> storeRoomAccountData(String roomId, BasicEvent event) async {
|
||||
await _roomAccountDataBox.put(
|
||||
TupleKey(roomId, event.type).toString(),
|
||||
event.toJson(),
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ class Room {
|
|||
Map<String, Map<String, StrippedStateEvent>> states = {};
|
||||
|
||||
/// Key-Value store for ephemerals.
|
||||
Map<String, BasicRoomEvent> ephemerals = {};
|
||||
Map<String, BasicEvent> ephemerals = {};
|
||||
|
||||
/// Key-Value store for private account data only visible for this user.
|
||||
Map<String, BasicRoomEvent> roomAccountData = {};
|
||||
Map<String, BasicEvent> roomAccountData = {};
|
||||
|
||||
final _sendingQueue = <Completer>[];
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ class Room {
|
|||
|
||||
Event? lastEvent;
|
||||
|
||||
void setEphemeral(BasicRoomEvent ephemeral) {
|
||||
void setEphemeral(BasicEvent ephemeral) {
|
||||
ephemerals[ephemeral.type] = ephemeral;
|
||||
if (ephemeral.type == 'm.typing') {
|
||||
_clearTypingIndicatorTimer?.cancel();
|
||||
|
|
@ -403,10 +403,10 @@ class Room {
|
|||
this.highlightCount = 0,
|
||||
this.prev_batch,
|
||||
required this.client,
|
||||
Map<String, BasicRoomEvent>? roomAccountData,
|
||||
Map<String, BasicEvent>? roomAccountData,
|
||||
RoomSummary? summary,
|
||||
this.lastEvent,
|
||||
}) : roomAccountData = roomAccountData ?? <String, BasicRoomEvent>{},
|
||||
}) : roomAccountData = roomAccountData ?? <String, BasicEvent>{},
|
||||
summary = summary ??
|
||||
RoomSummary.fromJson({
|
||||
'm.joined_member_count': 0,
|
||||
|
|
@ -572,9 +572,8 @@ class Room {
|
|||
join: {
|
||||
id: JoinedRoomUpdate(
|
||||
accountData: [
|
||||
BasicRoomEvent(
|
||||
BasicEvent(
|
||||
content: content,
|
||||
roomId: id,
|
||||
type: EventType.markedUnread,
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -257,10 +257,9 @@ void main() {
|
|||
|
||||
await database.storeRoomAccountData(
|
||||
roomid,
|
||||
BasicRoomEvent(
|
||||
BasicEvent(
|
||||
content: {'foo': 'bar'},
|
||||
type: 'm.test',
|
||||
roomId: roomid,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ void main() {
|
|||
'm.heroes': heroes,
|
||||
}),
|
||||
roomAccountData: {
|
||||
'com.test.foo': BasicRoomEvent(
|
||||
'com.test.foo': BasicEvent(
|
||||
type: 'com.test.foo',
|
||||
content: {'foo': 'bar'},
|
||||
),
|
||||
'm.fully_read': BasicRoomEvent(
|
||||
'm.fully_read': BasicEvent(
|
||||
type: 'm.fully_read',
|
||||
content: {'event_id': '\$event_id:example.com'},
|
||||
),
|
||||
|
|
@ -1292,7 +1292,7 @@ void main() {
|
|||
await room.addTag(TagType.favourite, order: 0.1);
|
||||
await room.removeTag(TagType.favourite);
|
||||
expect(room.isFavourite, false);
|
||||
room.roomAccountData['m.tag'] = BasicRoomEvent.fromJson({
|
||||
room.roomAccountData['m.tag'] = BasicEvent.fromJson({
|
||||
'content': {
|
||||
'tags': {
|
||||
'm.favourite': {'order': 0.1},
|
||||
|
|
@ -1311,7 +1311,7 @@ void main() {
|
|||
await room.markUnread(true);
|
||||
await room.markUnread(false);
|
||||
expect(room.markedUnread, false);
|
||||
room.roomAccountData['m.marked_unread'] = BasicRoomEvent.fromJson({
|
||||
room.roomAccountData['m.marked_unread'] = BasicEvent.fromJson({
|
||||
'content': {'unread': true},
|
||||
'type': 'm.marked_unread',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
timeline.events.first.eventId: {
|
||||
|
|
@ -294,7 +294,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
@ -328,7 +328,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
@ -371,7 +371,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
@ -421,7 +421,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$1': {
|
||||
|
|
@ -467,7 +467,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
@ -511,7 +511,7 @@ void main() {
|
|||
join: {
|
||||
timeline.room.id: JoinedRoomUpdate(
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
@ -559,7 +559,7 @@ void main() {
|
|||
],
|
||||
),
|
||||
ephemeral: [
|
||||
BasicRoomEvent.fromJson({
|
||||
BasicEvent.fromJson({
|
||||
'type': 'm.receipt',
|
||||
'content': {
|
||||
'\$2': {
|
||||
|
|
|
|||
Loading…
Reference in New Issue