migrate chatty
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class ChatUser {
|
||||
const ChatUser({this.name, this.image, this.id});
|
||||
final String name;
|
||||
final String image;
|
||||
final String id;
|
||||
final String? name;
|
||||
final String? image;
|
||||
final String? id;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
class CreateGroupInput {
|
||||
CreateGroupInput({this.imageFile, this.name, this.members});
|
||||
final File imageFile;
|
||||
final String name;
|
||||
final List<String> members;
|
||||
final File? imageFile;
|
||||
final String? name;
|
||||
final List<String?>? members;
|
||||
}
|
||||
|
||||
class CreateGroupUseCase {
|
||||
@@ -23,7 +23,7 @@ class CreateGroupUseCase {
|
||||
|
||||
Future<Channel> createGroup(CreateGroupInput input) async {
|
||||
final channelId = Uuid().v4();
|
||||
String image;
|
||||
String? image;
|
||||
if (input.imageFile != null) {
|
||||
image = await _uploadStorageRepository.uploadPhoto(
|
||||
input.imageFile, 'channels/$channelId');
|
||||
|
||||
@@ -5,10 +5,12 @@ import 'package:stream_chatter/data/stream_api_repository.dart';
|
||||
import 'package:stream_chatter/data/upload_storage_repository.dart';
|
||||
import 'package:stream_chatter/domain/models/chat_user.dart';
|
||||
|
||||
import '../exceptions/auth_exception.dart';
|
||||
|
||||
class ProfileInput {
|
||||
ProfileInput({this.imageFile, this.name});
|
||||
final File imageFile;
|
||||
final String name;
|
||||
final File? imageFile;
|
||||
final String? name;
|
||||
}
|
||||
|
||||
class ProfileSignInUseCase {
|
||||
@@ -24,13 +26,21 @@ class ProfileSignInUseCase {
|
||||
|
||||
Future<void> verify(ProfileInput input) async {
|
||||
final auth = await _authRepository.getAuthUser();
|
||||
if (auth == null) {
|
||||
throw AuthException(AuthErrorCode.not_auth);
|
||||
}
|
||||
final token = await _streamApiRepository.getToken(auth.id);
|
||||
String image;
|
||||
String? image;
|
||||
if (input.imageFile != null) {
|
||||
image = await _uploadStorageRepository.uploadPhoto(
|
||||
input.imageFile, 'users/${auth.id}');
|
||||
}
|
||||
await _streamApiRepository.connectUser(
|
||||
ChatUser(name: input.name, id: auth.id, image: image), token);
|
||||
ChatUser(
|
||||
name: input.name,
|
||||
id: auth.id,
|
||||
image: image,
|
||||
),
|
||||
token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user