implemented avatar management for user profiles and chat rooms, including 1:1 cropping, integrated OCS and Spreed avatar APIs, added cache invalidation logic, and updated the account settings view to display user info and profile pictures.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../api_params.dart';
|
||||
@@ -62,3 +64,44 @@ class DeleteMessage extends TalkApi {
|
||||
Map<String, String>? headers,
|
||||
) => http.delete(uri, headers: headers);
|
||||
}
|
||||
|
||||
class SetRoomAvatar extends TalkApi {
|
||||
final String chatToken;
|
||||
final Uint8List bytes;
|
||||
final String filename;
|
||||
|
||||
SetRoomAvatar(this.chatToken, this.bytes, {this.filename = 'avatar.jpg'})
|
||||
: super('v1/room/$chatToken/avatar', null);
|
||||
|
||||
@override
|
||||
ApiResponse? assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<http.Response> request(
|
||||
Uri uri,
|
||||
ApiParams? body,
|
||||
Map<String, String>? headers,
|
||||
) async {
|
||||
final req = http.MultipartRequest('POST', uri)
|
||||
..headers.addAll(headers ?? const {})
|
||||
..files.add(http.MultipartFile.fromBytes('file', bytes, filename: filename));
|
||||
final streamed = await req.send();
|
||||
return http.Response.fromStream(streamed);
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteRoomAvatar extends TalkApi {
|
||||
final String chatToken;
|
||||
|
||||
DeleteRoomAvatar(this.chatToken) : super('v1/room/$chatToken/avatar', null);
|
||||
|
||||
@override
|
||||
ApiResponse? assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<http.Response> request(
|
||||
Uri uri,
|
||||
ApiParams? body,
|
||||
Map<String, String>? headers,
|
||||
) => http.delete(uri, headers: headers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user