Merge branch 'send-location' of gitlab.com:JohnAZoidberg/famedlysdk into main
This commit is contained in:
commit
053585852e
|
@ -549,6 +549,17 @@ class Room {
|
||||||
}, type: EventTypes.Reaction, txid: txid);
|
}, type: EventTypes.Reaction, txid: txid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sends the location with description [body] and geo URI [geoUri] into a room.
|
||||||
|
/// Returns the event ID generated by the server for this message.
|
||||||
|
Future<String> sendLocation(String body, String geoUri, {String txid}) {
|
||||||
|
final event = <String, dynamic>{
|
||||||
|
'msgtype': 'm.location',
|
||||||
|
'body': body,
|
||||||
|
'geo_uri': geoUri,
|
||||||
|
};
|
||||||
|
return sendEvent(event, txid: txid);
|
||||||
|
}
|
||||||
|
|
||||||
/// Sends a [file] to this room after uploading it. Returns the mxc uri of
|
/// Sends a [file] to this room after uploading it. Returns the mxc uri of
|
||||||
/// the uploaded file. If [waitUntilSent] is true, the future will wait until
|
/// the uploaded file. If [waitUntilSent] is true, the future will wait until
|
||||||
/// the message event has received the server. Otherwise the future will only
|
/// the message event has received the server. Otherwise the future will only
|
||||||
|
|
|
@ -430,6 +430,25 @@ void main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('send location', () async {
|
||||||
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
|
|
||||||
|
final body = 'Middle of the ocean';
|
||||||
|
final geoUri = 'geo:0.0,0.0';
|
||||||
|
final dynamic resp =
|
||||||
|
await room.sendLocation(body, geoUri, txid: 'testtxid');
|
||||||
|
expect(resp.startsWith('\$event'), true);
|
||||||
|
|
||||||
|
final entry = FakeMatrixApi.calledEndpoints.entries
|
||||||
|
.firstWhere((p) => p.key.contains('/send/m.room.message/'));
|
||||||
|
final content = json.decode(entry.value.first);
|
||||||
|
expect(content, {
|
||||||
|
'msgtype': 'm.location',
|
||||||
|
'body': body,
|
||||||
|
'geo_uri': geoUri,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Not working because there is no real file to test it...
|
// Not working because there is no real file to test it...
|
||||||
/*test('sendImageEvent', () async {
|
/*test('sendImageEvent', () async {
|
||||||
final File testFile = File.fromUri(Uri.parse("fake/path/file.jpeg"));
|
final File testFile = File.fromUri(Uri.parse("fake/path/file.jpeg"));
|
||||||
|
|
Loading…
Reference in a new issue