Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
988 B

// import 'package:sqflite/sqflite.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import "package:pointycastle/export.dart";
import '/models/friends.dart';
import '/utils/storage/encryption_keys.dart';
import '/utils/storage/session_cookie.dart';
void getFriends() async {
RSAPrivateKey privKey = await getPrivateKey();
final resp = await http.get(
Uri.parse('http://192.168.1.5:8080/api/v1/auth/friends'),
headers: {
'cookie': await getSessionCookie(),
}
);
if (resp.statusCode != 200) {
throw Exception(resp.body);
}
List<Friend> friends = [];
List<dynamic> friendsJson = jsonDecode(resp.body);
for (var i = 0; i < friendsJson.length; i++) {
friends.add(
Friend.fromJson(
friendsJson[i] as Map<String, dynamic>,
privKey,
)
);
}
print(friends);
}