fix: 3pid api bugs

This commit is contained in:
Christian Pauly 2020-11-24 13:48:57 +01:00
parent 3850328000
commit 01ce832aaa
3 changed files with 10 additions and 7 deletions

View File

@ -517,15 +517,15 @@ class MatrixApi {
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-delete /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-delete
Future<IdServerUnbindResult> deleteThirdPartyIdentifier( Future<IdServerUnbindResult> deleteThirdPartyIdentifier(
String address, String address,
ThirdPartyIdentifierMedium medium, ThirdPartyIdentifierMedium medium, {
String idServer, String idServer,
) async { }) async {
final response = await request( final response = await request(
RequestType.POST, '/client/r0/account/3pid/delete', RequestType.POST, '/client/r0/account/3pid/delete',
data: { data: {
'address': address, 'address': address,
'medium': describeEnum(medium), 'medium': describeEnum(medium),
'id_server': idServer, if (idServer != null) 'id_server': idServer,
}); });
return IdServerUnbindResult.values.firstWhere( return IdServerUnbindResult.values.firstWhere(
(i) => describeEnum(i) == response['id_server_unbind_result'], (i) => describeEnum(i) == response['id_server_unbind_result'],

View File

@ -16,14 +16,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import 'package:famedlysdk/matrix_api.dart';
class ThirdPartyIdentifier { class ThirdPartyIdentifier {
String medium; ThirdPartyIdentifierMedium medium;
String address; String address;
int validatedAt; int validatedAt;
int addedAt; int addedAt;
ThirdPartyIdentifier.fromJson(Map<String, dynamic> json) { ThirdPartyIdentifier.fromJson(Map<String, dynamic> json) {
medium = json['medium']; medium = ThirdPartyIdentifierMedium.values
.firstWhere((medium) => describeEnum(medium) == json['medium']);
address = json['address']; address = json['address'];
validatedAt = json['validated_at']; validatedAt = json['validated_at'];
addedAt = json['added_at']; addedAt = json['added_at'];
@ -31,7 +34,7 @@ class ThirdPartyIdentifier {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final data = <String, dynamic>{}; final data = <String, dynamic>{};
data['medium'] = medium; data['medium'] = describeEnum(medium);
data['address'] = address; data['address'] = address;
data['validated_at'] = validatedAt; data['validated_at'] = validatedAt;
data['added_at'] = addedAt; data['added_at'] = addedAt;

View File

@ -287,7 +287,7 @@ void main() {
final response = await matrixApi.deleteThirdPartyIdentifier( final response = await matrixApi.deleteThirdPartyIdentifier(
'alice@example.com', 'alice@example.com',
ThirdPartyIdentifierMedium.email, ThirdPartyIdentifierMedium.email,
'https://example.com', idServer: 'https://example.com',
); );
expect(response, IdServerUnbindResult.success); expect(response, IdServerUnbindResult.success);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;