|
1 | | -using Microsoft.AspNetCore.Components.Forms; |
| 1 | +using BlazorBootstrap; |
| 2 | +using Microsoft.AspNetCore.Components.Forms; |
2 | 3 | using Microsoft.AspNetCore.StaticFiles; |
3 | 4 | using Microsoft.Extensions.Logging; |
4 | 5 | using MongoDB.Driver; |
@@ -232,15 +233,17 @@ public class FileService : IFileService |
232 | 233 | private IDbService _db { get; set; } |
233 | 234 | private ILogger<IFileService> _logger { get; set; } |
234 | 235 | private TransactionInfoService _tis { get; set; } |
| 236 | + private ToastService _toastService { get; set; } |
235 | 237 |
|
236 | 238 | const int MaxSize = 1024 * 1024 * 1000; // 1GB |
237 | 239 |
|
238 | 240 |
|
239 | | - public FileService(ITelegramService ts, IDbService db, ILogger<IFileService> logger, TransactionInfoService tis) |
| 241 | + public FileService(ITelegramService ts, IDbService db, ILogger<IFileService> logger, TransactionInfoService tis, ToastService toastService) |
240 | 242 | { |
241 | 243 | _ts = ts; |
242 | 244 | _db = db; |
243 | 245 | _tis = tis; |
| 246 | + _toastService = toastService; |
244 | 247 | _logger = logger; |
245 | 248 | createTempFolder(); |
246 | 249 | } |
@@ -736,7 +739,13 @@ private async Task downloadFromTelegram(string dbName, int messageId, string des |
736 | 739 | } |
737 | 740 | model._transmitted = 0; |
738 | 741 | model.callbacks = new Callbacks(); |
739 | | - model.channelName = _ts.getChatName(Convert.ToInt64(dbName)); |
| 742 | + try |
| 743 | + { |
| 744 | + model.channelName = _ts.getChatName(Convert.ToInt64(dbName)); |
| 745 | + } catch(Exception ex) { |
| 746 | + model.channelName = "Public or Shared"; |
| 747 | + } |
| 748 | + |
740 | 749 | model.callbacks.callback = async () => await DownloadFileNow(dbName, messageId, destPath, model); |
741 | 750 | _tis.addToPendingDownloadList(model); |
742 | 751 | } |
@@ -831,6 +840,19 @@ public async Task importSharedData(ShareFilesModel sfm, GenericNotificationProgr |
831 | 840 |
|
832 | 841 | try |
833 | 842 | { |
| 843 | + if (!_ts.isInChat(Convert.ToInt64(sfm.id)) && sfm.invitation != null && !string.IsNullOrEmpty(sfm.invitation.invitationHash)) |
| 844 | + try |
| 845 | + { |
| 846 | + await _ts.joinChatInvitationHash(sfm.invitation.invitationHash); |
| 847 | + _toastService.Notify(new(ToastType.Success, "Join chat", $"Joined to chat")); |
| 848 | + } |
| 849 | + catch (Exception ex) |
| 850 | + { |
| 851 | + _toastService.Notify(new(ToastType.Danger, $"Error: {ex.Message}.")); |
| 852 | + } |
| 853 | + else |
| 854 | + _toastService.Notify(new(ToastType.Info, "You were already joined the chat")); |
| 855 | + |
834 | 856 | BsonSharedInfoModel bsi = new BsonSharedInfoModel(); |
835 | 857 | bsi.ChannelId = sfm.id; |
836 | 858 | bsi.Name = sfm.name; |
|
0 commit comments