@@ -796,6 +796,7 @@ public static void functionCalll(string dbName, int messageId, string destPath)
796796 private async Task downloadFromTelegram ( string dbName , int messageId , string destPath , BsonFileManagerModel file = null )
797797 {
798798 DownloadModel model = new DownloadModel ( ) ;
799+ model . tis = _tis ;
799800 if ( file != null )
800801 {
801802 model . name = file . Name ;
@@ -817,7 +818,11 @@ private async Task downloadFromTelegram(string dbName, int messageId, string des
817818 public async Task DownloadFileFromChat ( ChatMessages message , string fileName = null , string folder = null , DownloadModel model = null )
818819 {
819820 if ( model == null )
821+ {
820822 model = new DownloadModel ( ) ;
823+ model . tis = _tis ;
824+ }
825+
821826 model . name = fileName ;
822827 if ( message . message . media is MessageMediaDocument { document : Document document } )
823828 {
@@ -1099,6 +1104,7 @@ public async Task CreateDatabase(string id)
10991104 public async Task AddUploadFileFromServer ( string dbName , string currentPath , List < Syncfusion . Blazor . FileManager . FileManagerDirectoryContent > files , InfoDownloadTaksModel idt = null ) // ItemsUploadedEventArgs<FileManagerDirectoryContent> args)
11001105 {
11011106 idt = new InfoDownloadTaksModel ( ) ;
1107+ idt . tis = _tis ;
11021108 idt . id = Guid . NewGuid ( ) . ToString ( ) ;
11031109 idt . total = 0 ;
11041110 idt . totalSize = 0 ;
@@ -1135,9 +1141,8 @@ public async Task AddUploadFileFromServer(string dbName, string currentPath, Lis
11351141 }
11361142 idt . callbacks = new Callbacks ( ) ;
11371143 idt . callbacks . callback = async ( ) => await UploadFileFromServer ( dbName , currentPath , files , idt ) ;
1138- TransactionInfoService ti = new TransactionInfoService ( ) ;
1139- ti . addToInfoDownloadTaskList ( idt ) ;
1140- ti . CheckPendingUploadInfoTasks ( ) ;
1144+ _tis . addToInfoDownloadTaskList ( idt ) ;
1145+ _tis . CheckPendingUploadInfoTasks ( ) ;
11411146 }
11421147
11431148
@@ -1254,6 +1259,7 @@ public async Task UploadFileFromServer(string dbName, string currentPath, List<S
12541259 int attempts = 3 ;
12551260 int waitForNextAttempt = 1000 ;
12561261 UploadModel um = new UploadModel ( ) ;
1262+ um . tis = _tis ;
12571263 um . path = currentFilePath ;
12581264 um . chatName = _ts . getChatName ( Convert . ToInt64 ( dbName ) ) ;
12591265 // add upload to task list
@@ -1264,7 +1270,7 @@ public async Task UploadFileFromServer(string dbName, string currentPath, List<S
12641270 {
12651271 wt = new WaitingTime ( ) ;
12661272 using ( FileStream fs = new FileStream ( s , FileMode . Open , FileAccess . Read , FileShare . Read ) )
1267- m = await _ts . uploadFile ( dbName , fs , $ "({ i } of { filesSplit . Count } ) - " + file . Name , um : um ) ;
1273+ m = await _ts . uploadFile ( dbName , fs , $ "({ i } of { filesSplit . Count } ) - " + file . Name , um : um , caption : getCaption ( filePath ) ) ;
12681274 attempts = 0 ;
12691275 await wt . Sleep ( ) ; // sleep 1 second to avoid 420 flood_wait_x
12701276 }
@@ -1303,6 +1309,7 @@ public async Task UploadFileFromServer(string dbName, string currentPath, List<S
13031309 int attempts = 3 ;
13041310 int waitForNextAttempt = 60000 ;
13051311 UploadModel um = new UploadModel ( ) ;
1312+ um . tis = _tis ;
13061313 um . path = currentFilePath ;
13071314 um . chatName = _ts . getChatName ( Convert . ToInt64 ( dbName ) ) ;
13081315 // add upload to task list
@@ -1317,17 +1324,17 @@ public async Task UploadFileFromServer(string dbName, string currentPath, List<S
13171324 using ( FileStream ms = new FileStream ( System . IO . Path . Combine ( currentFilePath ) , FileMode . Open ) )
13181325 if ( ImageExtensions . Any ( x => file . Name . ToUpper ( ) . EndsWith ( x ) ) && file . Size >= MAXIMAGESIZE )
13191326 {
1320- m = await _ts . uploadFile ( dbName , ms , file . Name , "application/octet-stream" , um ) ;
1327+ m = await _ts . uploadFile ( dbName , ms , file . Name , "application/octet-stream" , um , caption : getCaption ( filePath ) ) ;
13211328 }
13221329 else
1323- m = await _ts . uploadFile ( dbName , ms , file . Name , um : um ) ;
1330+ m = await _ts . uploadFile ( dbName , ms , file . Name , um : um , caption : getCaption ( filePath ) ) ;
13241331 }
13251332 catch ( Exception ex )
13261333 {
13271334 if ( new List < string > { "IMAGE" , "PHOTO" } . Any ( x => ex . Message . Contains ( x ) ) )
13281335 {
13291336 using ( FileStream ms = new FileStream ( System . IO . Path . Combine ( currentFilePath ) , FileMode . Open ) )
1330- m = await _ts . uploadFile ( dbName , ms , file . Name , "application/octet-stream" , um ) ;
1337+ m = await _ts . uploadFile ( dbName , ms , file . Name , "application/octet-stream" , um , caption : getCaption ( filePath ) ) ;
13311338 }
13321339 else
13331340 {
@@ -1508,7 +1515,7 @@ public async Task UploadFile(string dbName, string currentPath, UploadFiles file
15081515 foreach ( string s in files )
15091516 {
15101517 using ( FileStream fs = new FileStream ( s , FileMode . Open , FileAccess . Read , FileShare . Read ) )
1511- m = await _ts . uploadFile ( dbName , fs , $ "({ i } of { files . Count } ) - " + file . File . Name ) ;
1518+ m = await _ts . uploadFile ( dbName , fs , $ "({ i } of { files . Count } ) - " + file . File . Name , caption : getCaption ( currentPath ) ) ;
15121519 model . ListMessageId . Add ( m . ID ) ;
15131520 File . Delete ( s ) ;
15141521 i ++ ;
@@ -1519,7 +1526,7 @@ public async Task UploadFile(string dbName, string currentPath, UploadFiles file
15191526 {
15201527 using ( FileStream ms = new FileStream ( System . IO . Path . Combine ( currentFilePath , file . File . Name ) , FileMode . Open ) )
15211528 {
1522- m = await _ts . uploadFile ( dbName , ms , file . File . Name ) ;
1529+ m = await _ts . uploadFile ( dbName , ms , file . File . Name , caption : getCaption ( currentPath ) ) ;
15231530 }
15241531 model . MessageId = m . ID ;
15251532 }
@@ -1751,6 +1758,11 @@ private async Task<List<ExpandoObject>> AddChildRecords(string id, string parent
17511758 return response ;
17521759 }
17531760
1761+ private string ? getCaption ( string filePath )
1762+ {
1763+ return GeneralConfigStatic . config . ShouldShowCaptionPath ? filePath : null ;
1764+ }
1765+
17541766 private async Task < MemoryStream > ToMemoryStreamAsync ( Stream stream )
17551767 {
17561768 var memoryStream = new MemoryStream ( ) ;
0 commit comments