mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Compare commits
10 Commits
PM-171-rem
...
community/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da62d8211 | ||
|
|
c5f1df6e4c | ||
|
|
cd45992e6b | ||
|
|
ed75aa7942 | ||
|
|
743bf06b24 | ||
|
|
73f3ffceb2 | ||
|
|
39881d2c7f | ||
|
|
5aaff1ea20 | ||
|
|
fc79042212 | ||
|
|
dc6a0bbd33 |
@@ -7,6 +7,7 @@
|
||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||
xmlns:core="clr-namespace:Bit.Core;assembly=BitwardenCore"
|
||||
x:DataType="pages:BlockAutofillUrisPageViewModel"
|
||||
NavigationPage.HasBackButton="False"
|
||||
Title="{u:I18n BlockAutoFill}">
|
||||
<ContentPage.BindingContext>
|
||||
<pages:BlockAutofillUrisPageViewModel />
|
||||
|
||||
@@ -409,6 +409,12 @@ namespace Bit.App.Pages
|
||||
AppResources.InternetConnectionRequiredTitle);
|
||||
return false;
|
||||
}
|
||||
var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToRestoreCipher,
|
||||
null, AppResources.Yes, AppResources.Cancel);
|
||||
if (!confirmed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
await _deviceActionService.ShowLoadingAsync(AppResources.Restoring);
|
||||
|
||||
9
src/App/Resources/AppResources.Designer.cs
generated
9
src/App/Resources/AppResources.Designer.cs
generated
@@ -2092,6 +2092,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Do you really want to restore this item?.
|
||||
/// </summary>
|
||||
public static string DoYouReallyWantToRestoreCipher {
|
||||
get {
|
||||
return ResourceManager.GetString("DoYouReallyWantToRestoreCipher", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Do you really want to send to the trash?.
|
||||
/// </summary>
|
||||
|
||||
@@ -1741,6 +1741,10 @@ Scanning will happen automatically.</value>
|
||||
<value>Do you really want to permanently delete? This cannot be undone.</value>
|
||||
<comment>Confirmation alert message when permanently deleteing a cipher.</comment>
|
||||
</data>
|
||||
<data name="DoYouReallyWantToRestoreCipher" xml:space="preserve">
|
||||
<value>Do you really want to restore this item?</value>
|
||||
<comment>Confirmation alert message when restoring a soft-deleted cipher.</comment>
|
||||
</data>
|
||||
<data name="DoYouReallyWantToSoftDeleteCipher" xml:space="preserve">
|
||||
<value>Do you really want to send to the trash?</value>
|
||||
<comment>Confirmation alert message when soft-deleting a cipher.</comment>
|
||||
|
||||
@@ -131,6 +131,24 @@ namespace Bit.App.Services
|
||||
_messagingService.Value.Send("logout");
|
||||
}
|
||||
break;
|
||||
case NotificationType.SyncSendCreate:
|
||||
case NotificationType.SyncSendUpdate:
|
||||
var sendCreateUpdateMessage = JsonConvert.DeserializeObject<SyncSendNotification>(
|
||||
notification.Payload);
|
||||
if (isAuthenticated && sendCreateUpdateMessage.UserId == myUserId)
|
||||
{
|
||||
await _syncService.Value.SyncUpsertSendAsync(sendCreateUpdateMessage,
|
||||
notification.Type == NotificationType.SyncSendUpdate);
|
||||
}
|
||||
break;
|
||||
case NotificationType.SyncSendDelete:
|
||||
var sendDeleteMessage = JsonConvert.DeserializeObject<SyncSendNotification>(
|
||||
notification.Payload);
|
||||
if (isAuthenticated && sendDeleteMessage.UserId == myUserId)
|
||||
{
|
||||
await _syncService.Value.SyncDeleteSendAsync(sendDeleteMessage);
|
||||
}
|
||||
break;
|
||||
case NotificationType.AuthRequest:
|
||||
var passwordlessLoginMessage = JsonConvert.DeserializeObject<PasswordlessRequestNotification>(notification.Payload);
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ namespace Bit.Core.Abstractions
|
||||
Task SetLastSyncAsync(DateTime date);
|
||||
Task<bool> SyncDeleteCipherAsync(SyncCipherNotification notification);
|
||||
Task<bool> SyncDeleteFolderAsync(SyncFolderNotification notification);
|
||||
Task<bool> SyncDeleteSendAsync(SyncSendNotification notification);
|
||||
Task<bool> SyncUpsertCipherAsync(SyncCipherNotification notification, bool isEdit);
|
||||
Task<bool> SyncUpsertFolderAsync(SyncFolderNotification notification, bool isEdit);
|
||||
Task<bool> SyncUpsertSendAsync(SyncSendNotification notification, bool isEdit);
|
||||
// Passwordless code will be moved to an independent service in future techdept
|
||||
Task SyncPasswordlessLoginRequestsAsync();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ namespace Bit.Core.Models.Response
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
|
||||
public class SyncSendNotification
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
|
||||
public class PasswordlessRequestNotification
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
|
||||
@@ -274,6 +274,66 @@ namespace Bit.Core.Services
|
||||
return SyncCompleted(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SyncUpsertSendAsync(SyncSendNotification notification, bool isEdit)
|
||||
{
|
||||
SyncStarted();
|
||||
if (!await _stateService.IsAuthenticatedAsync())
|
||||
{
|
||||
return SyncCompleted(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var localSend = await _sendService.GetAsync(notification.Id);
|
||||
if ((localSend != null && localSend.RevisionDate >= notification.RevisionDate)
|
||||
|| (isEdit && localSend == null) || (!isEdit && localSend != null))
|
||||
{
|
||||
return SyncCompleted(false);
|
||||
}
|
||||
|
||||
var remoteSend = await _apiService.GetSendAsync(notification.Id);
|
||||
if (remoteSend != null)
|
||||
{
|
||||
var userId = await _stateService.GetActiveUserIdAsync();
|
||||
await _sendService.UpsertAsync(new SendData(remoteSend, userId));
|
||||
_messagingService.Send("syncedUpsertedSend", new Dictionary<string, string>
|
||||
{
|
||||
["sendId"] = notification.Id
|
||||
});
|
||||
return SyncCompleted(true);
|
||||
}
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
if (e.Error != null && e.Error.StatusCode == System.Net.HttpStatusCode.NotFound && isEdit)
|
||||
{
|
||||
await _sendService.DeleteAsync(notification.Id);
|
||||
_messagingService.Send("syncedDeletedSend", new Dictionary<string, string>
|
||||
{
|
||||
["sendId"] = notification.Id
|
||||
});
|
||||
return SyncCompleted(true);
|
||||
}
|
||||
}
|
||||
|
||||
return SyncCompleted(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SyncDeleteSendAsync(SyncSendNotification notification)
|
||||
{
|
||||
SyncStarted();
|
||||
if (await _stateService.IsAuthenticatedAsync())
|
||||
{
|
||||
await _sendService.DeleteAsync(notification.Id);
|
||||
_messagingService.Send("syncedDeletedSend", new Dictionary<string, string>
|
||||
{
|
||||
["sendId"] = notification.Id
|
||||
});
|
||||
return SyncCompleted(true);
|
||||
}
|
||||
return SyncCompleted(false);
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
private void SyncStarted()
|
||||
|
||||
Reference in New Issue
Block a user