ToggleLocationSharing returns bool
This commit is contained in:
Submodule LightlessAPI updated: 852e2a005f...c3caa7e25c
@@ -1322,16 +1322,27 @@ public partial class LightlessHub
|
|||||||
|
|
||||||
|
|
||||||
[Authorize(Policy = "Identified")]
|
[Authorize(Policy = "Identified")]
|
||||||
public async Task ToggleLocationSharing(LocationSharingToggleDto dto)
|
public async Task<bool> ToggleLocationSharing(LocationSharingToggleDto dto)
|
||||||
{
|
{
|
||||||
_logger.LogCallInfo(LightlessHubLogger.Args(UserUID,dto));
|
_logger.LogCallInfo(LightlessHubLogger.Args(UserUID,dto));
|
||||||
await DbContext.Permissions.Where(x => x.UserUID == UserUID && dto.users.Contains(x.OtherUserUID))
|
try
|
||||||
.ExecuteUpdateAsync(setter =>
|
{
|
||||||
setter.SetProperty(x => x.ShareLocationUntil, dto.duration.ToUniversalTime()), cancellationToken: RequestAbortedToken).ConfigureAwait(false);
|
await DbContext.Permissions.Where(x => x.UserUID == UserUID && dto.users.Contains(x.OtherUserUID))
|
||||||
|
.ExecuteUpdateAsync(setter =>
|
||||||
//update user's location for target users
|
setter.SetProperty(x => x.ShareLocationUntil, dto.duration.ToUniversalTime()),
|
||||||
var currentLocation = await _redis.GetAsync<LocationDto>($"Location:{UserUID}").ConfigureAwait(false);
|
cancellationToken: RequestAbortedToken).ConfigureAwait(false);
|
||||||
await Clients.Users(dto.users).Client_SendLocationToClient(currentLocation, dto.duration.ToUniversalTime()).ConfigureAwait(false);
|
|
||||||
|
//update user's location for target users
|
||||||
|
var currentLocation = await _redis.GetAsync<LocationDto>($"Location:{UserUID}").ConfigureAwait(false);
|
||||||
|
await Clients.Users(dto.users).Client_SendLocationToClient(currentLocation, dto.duration.ToUniversalTime())
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "ToggleLocationSharing error:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[GeneratedRegex(@"^([a-z0-9_ '+&,\.\-\{\}]+\/)+([a-z0-9_ '+&,\.\-\{\}]+\.[a-z]{3,4})$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ECMAScript)]
|
[GeneratedRegex(@"^([a-z0-9_ '+&,\.\-\{\}]+\/)+([a-z0-9_ '+&,\.\-\{\}]+\.[a-z]{3,4})$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ECMAScript)]
|
||||||
|
|||||||
Reference in New Issue
Block a user