.github
android
api
assets
debian
drift_schemas
ios
lib
controllers
database
providers
channel.dart
chat_call.dart
config.dart
database.dart
experience.dart
keypair.dart
link_preview.dart
navigation.dart
notification.dart
post.dart
relationship.dart
sn_attachment.dart
sn_network.dart
sn_realm.dart
sn_sticker.dart
special_day.dart
theme.dart
translation.dart
user_directory.dart
userinfo.dart
websocket.dart
widget.dart
screens
types
widgets
firebase_options.dart
logger.dart
main.dart
router.dart
theme.dart
linux
macos
snap
test
web
windows
.gitignore
.metadata
.roadsignrc
README.md
analysis_options.yaml
build.yaml
devtools_options.yaml
firebase.json
pubspec.lock
pubspec.yaml
roadsign.toml
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:surface/providers/sn_network.dart';
|
|
import 'package:surface/types/account.dart';
|
|
|
|
class SnRelationshipProvider {
|
|
late final SnNetworkProvider _sn;
|
|
|
|
SnRelationshipProvider(BuildContext context) {
|
|
_sn = context.read<SnNetworkProvider>();
|
|
}
|
|
|
|
Future<SnRelationship?> getRelationship(int relatedId) async {
|
|
try {
|
|
final resp = await _sn.client.get('/cgi/id/users/me/relations/$relatedId');
|
|
return SnRelationship.fromJson(resp.data);
|
|
} catch (err) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
Future<void> updateRelationship(
|
|
int relatedId,
|
|
int status,
|
|
Map<String, dynamic> permNodes,
|
|
) async {
|
|
await _sn.client.put('/cgi/id/users/me/relations/$relatedId', data: {
|
|
'status': status,
|
|
'perm_nodes': permNodes,
|
|
});
|
|
}
|
|
|
|
Future<void> deleteRelationship(int relatedId) async {
|
|
await _sn.client.delete('/cgi/id/users/me/relations/$relatedId');
|
|
}
|
|
|
|
Future<void> acceptFriendRequest(int relatedId) async {
|
|
await _sn.client.post('/cgi/id/users/me/relations/$relatedId/accept');
|
|
}
|
|
|
|
Future<void> declineFriendRequest(int relatedId) async {
|
|
await _sn.client.post('/cgi/id/users/me/relations/$relatedId/decline');
|
|
}
|
|
}
|