nc-photos/app/lib/use_case/list_share.dart

40 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:logging/logging.dart';
2021-08-07 22:34:44 +02:00
import 'package:nc_photos/account.dart';
import 'package:nc_photos/debug_util.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
2021-08-07 22:34:44 +02:00
import 'package:nc_photos/entity/share.dart';
import 'package:nc_photos/use_case/find_file.dart';
2022-12-16 16:01:04 +01:00
import 'package:np_codegen/np_codegen.dart';
part 'list_share.g.dart';
2021-08-07 22:34:44 +02:00
/// List all shares from a given file
2022-12-16 16:01:04 +01:00
@npLog
2021-08-07 22:34:44 +02:00
class ListShare {
const ListShare(this._c);
2021-08-07 22:34:44 +02:00
Future<List<Share>> call(
Account account,
FileDescriptor file, {
bool? isIncludeReshare,
}) async {
try {
if (file_util.getUserDirNamePath(file.fdPath) != account.userId) {
file = (await FindFile(_c)(account, [file.fdId])).first;
}
} catch (_) {
// file not found
_log.warning("[call] File not found in db: ${logFilename(file.fdPath)}");
}
return _c.shareRepo.list(
account,
file,
isIncludeReshare: isIncludeReshare,
);
}
2021-08-07 22:34:44 +02:00
final DiContainer _c;
2021-08-07 22:34:44 +02:00
}