2021-10-17 11:45:56 +02:00
|
|
|
import 'package:event_bus/event_bus.dart';
|
|
|
|
import 'package:kiwi/kiwi.dart';
|
2021-09-28 08:36:00 +02:00
|
|
|
import 'package:nc_photos/account.dart';
|
|
|
|
import 'package:nc_photos/entity/file.dart';
|
|
|
|
import 'package:nc_photos/entity/share.dart';
|
2021-10-17 11:45:56 +02:00
|
|
|
import 'package:nc_photos/event/event.dart';
|
2021-09-28 08:36:00 +02:00
|
|
|
|
2021-09-28 08:37:16 +02:00
|
|
|
class CreateUserShare {
|
|
|
|
const CreateUserShare(this.shareRepo);
|
|
|
|
|
2021-10-17 11:45:56 +02:00
|
|
|
Future<Share> call(Account account, File file, String shareWith) async {
|
|
|
|
final share = await shareRepo.create(account, file, shareWith);
|
|
|
|
KiwiContainer().resolve<EventBus>().fire(ShareCreatedEvent(account, share));
|
|
|
|
return share;
|
|
|
|
}
|
2021-09-28 08:37:16 +02:00
|
|
|
|
|
|
|
final ShareRepo shareRepo;
|
|
|
|
}
|
|
|
|
|
2021-09-28 08:36:00 +02:00
|
|
|
class CreateLinkShare {
|
|
|
|
const CreateLinkShare(this.shareRepo);
|
|
|
|
|
|
|
|
Future<Share> call(
|
|
|
|
Account account,
|
|
|
|
File file, {
|
|
|
|
String? password,
|
2021-10-17 11:45:56 +02:00
|
|
|
}) async {
|
|
|
|
final share = await shareRepo.createLink(account, file, password: password);
|
|
|
|
KiwiContainer().resolve<EventBus>().fire(ShareCreatedEvent(account, share));
|
|
|
|
return share;
|
|
|
|
}
|
2021-09-28 08:36:00 +02:00
|
|
|
|
|
|
|
final ShareRepo shareRepo;
|
|
|
|
}
|