|
10 | 10 |
|
11 | 11 | using Syncfusion.EJ2.FileManager.PhysicalFileProvider; |
12 | 12 | using Syncfusion.EJ2.Linq; |
| 13 | +using Syncfusion.EJ2.Notifications; |
13 | 14 | using System.Dynamic; |
14 | 15 | using System.IO.Compression; |
15 | 16 | using System.Security.Cryptography; |
@@ -706,7 +707,7 @@ public async Task downloadFile(string dbName, List<FileManagerDirectoryContent> |
706 | 707 |
|
707 | 708 | private async Task<MemoryStream> downloadFromTelegramAndReturn(string dbName, int messageId, string destPath, MemoryStream ms = null) |
708 | 709 | { |
709 | | - Message m = await _ts.getMessageFile(dbName, messageId); |
| 710 | + TL.Message m = await _ts.getMessageFile(dbName, messageId); |
710 | 711 | ChatMessages cm = new ChatMessages(); |
711 | 712 | cm.message = m; |
712 | 713 |
|
@@ -750,6 +751,28 @@ private async Task downloadFromTelegram(string dbName, int messageId, string des |
750 | 751 | _tis.addToPendingDownloadList(model); |
751 | 752 | } |
752 | 753 |
|
| 754 | + public async Task DownloadFileFromChat(ChatMessages message, string fileName = null, string folder = null, DownloadModel model = null) |
| 755 | + { |
| 756 | + if (model == null) |
| 757 | + model = new DownloadModel(); |
| 758 | + model.name = fileName; |
| 759 | + if (message.message.media is MessageMediaDocument { document: Document document }) |
| 760 | + { |
| 761 | + model._size = document.size; |
| 762 | + } |
| 763 | + if (message.user is Channel channel) |
| 764 | + { |
| 765 | + model.channelName = channel.Title; |
| 766 | + } |
| 767 | + model._transmitted = 0; |
| 768 | + model.channel = message.user; |
| 769 | + //model.channelName = message.user.; |
| 770 | + model.callbacks = new Callbacks(); |
| 771 | + |
| 772 | + model.callbacks.callback = async () => await _ts.DownloadFile(message,fileName, folder, model); |
| 773 | + _tis.addToPendingDownloadList(model); |
| 774 | + } |
| 775 | + |
753 | 776 | public async Task DownloadFileNow(string dbName, int messageId, string destPath, DownloadModel model) |
754 | 777 | { |
755 | 778 | TL.Message m = await _ts.getMessageFile(dbName, messageId); |
@@ -1149,7 +1172,7 @@ public async Task UploadFileFromServer(string dbName, string currentPath, List<S |
1149 | 1172 | _logger.LogInformation($"Calculating MD5 of file {currentFilePath}"); |
1150 | 1173 | model.MD5Hash = GetMd5HashFromFile(currentFilePath); |
1151 | 1174 | _logger.LogInformation($"Calculated MD5 of file {currentFilePath}: {model.MD5Hash}"); |
1152 | | - Message m = null; |
| 1175 | + TL.Message m = null; |
1153 | 1176 | long max = (long)MaxSize * (long)TelegramService.splitSizeGB; |
1154 | 1177 | if (fileInfo.Length > max) |
1155 | 1178 | { |
@@ -1398,7 +1421,7 @@ public async Task UploadFile(string dbName, string currentPath, UploadFiles file |
1398 | 1421 |
|
1399 | 1422 | BsonFileManagerModel model = new BsonFileManagerModel(); |
1400 | 1423 | model.Size = file.File.Size; |
1401 | | - Message m = null; |
| 1424 | + TL.Message m = null; |
1402 | 1425 | if (file.File.Size > MaxSize) |
1403 | 1426 | { |
1404 | 1427 |
|
|
0 commit comments