import '../files_sharing/file_sharing_api.dart';
import '../files_sharing/file_sharing_api_params.dart';

/// WebDAV folder under which Talk-shared files are uploaded before being
/// linked into a chat.
const String talkShareFolder = 'MarianumMobile';

/// Posts each already-uploaded WebDAV path as a Talk share (ShareType 10) to
/// the given conversation token. Calls run concurrently — the server accepts
/// parallel posts and the picker UI is blocked anyway, so we shouldn't pay
/// O(n*RTT) latency per share.
Future<void> shareFilesToChat({
  required String token,
  required List<String> remoteFilePaths,
}) => Future.wait(
  remoteFilePaths.map(
    (path) => FileSharingApi().share(
      FileSharingApiParams(shareType: 10, shareWith: token, path: path),
    ),
  ),
);
