fix: 3pid api bugs
This commit is contained in:
parent
3850328000
commit
01ce832aaa
|
|
@ -517,15 +517,15 @@ class MatrixApi {
|
|||
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-delete
|
||||
Future<IdServerUnbindResult> deleteThirdPartyIdentifier(
|
||||
String address,
|
||||
ThirdPartyIdentifierMedium medium,
|
||||
ThirdPartyIdentifierMedium medium, {
|
||||
String idServer,
|
||||
) async {
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/account/3pid/delete',
|
||||
data: {
|
||||
'address': address,
|
||||
'medium': describeEnum(medium),
|
||||
'id_server': idServer,
|
||||
if (idServer != null) 'id_server': idServer,
|
||||
});
|
||||
return IdServerUnbindResult.values.firstWhere(
|
||||
(i) => describeEnum(i) == response['id_server_unbind_result'],
|
||||
|
|
|
|||
|
|
@ -16,14 +16,17 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
|
||||
class ThirdPartyIdentifier {
|
||||
String medium;
|
||||
ThirdPartyIdentifierMedium medium;
|
||||
String address;
|
||||
int validatedAt;
|
||||
int addedAt;
|
||||
|
||||
ThirdPartyIdentifier.fromJson(Map<String, dynamic> json) {
|
||||
medium = json['medium'];
|
||||
medium = ThirdPartyIdentifierMedium.values
|
||||
.firstWhere((medium) => describeEnum(medium) == json['medium']);
|
||||
address = json['address'];
|
||||
validatedAt = json['validated_at'];
|
||||
addedAt = json['added_at'];
|
||||
|
|
@ -31,7 +34,7 @@ class ThirdPartyIdentifier {
|
|||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['medium'] = medium;
|
||||
data['medium'] = describeEnum(medium);
|
||||
data['address'] = address;
|
||||
data['validated_at'] = validatedAt;
|
||||
data['added_at'] = addedAt;
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ void main() {
|
|||
final response = await matrixApi.deleteThirdPartyIdentifier(
|
||||
'alice@example.com',
|
||||
ThirdPartyIdentifierMedium.email,
|
||||
'https://example.com',
|
||||
idServer: 'https://example.com',
|
||||
);
|
||||
expect(response, IdServerUnbindResult.success);
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue