-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added check that device id is not already attached to plant upon update
- Loading branch information
1 parent
91c04d0
commit cabeb4e
Showing
5 changed files
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using api.Core.Services; | ||
using api.Core.Services.External.BlobStorage; | ||
using api.Events.Auth.Server; | ||
using api.Events.Collections.Server; | ||
using api.Events.Global; | ||
using api.Events.PlantEvents.Server; | ||
using api.Events.Statistics; | ||
using api.Extensions; | ||
using Fleck; | ||
using Shared.Dtos; | ||
|
||
namespace api.Events.Auth.Client; | ||
|
||
public class InitialDataHelper(PlantService plantService, IBlobStorageService blobStorageService, CollectionsService collectionsService, StatsService statsService, UserService userService, WebSocketConnectionService webSocketConnectionService, JwtService jwtService) | ||
{ | ||
|
||
public async Task SendInitialData(IWebSocketConnection socket, string jwt) | ||
{ | ||
var email = jwtService.GetEmailFromJwt(jwt); | ||
webSocketConnectionService.UpdateConnectionEmail(socket, email); | ||
|
||
var user = await userService.GetUserByEmail(email); | ||
|
||
socket.SendDto(new ServerAuthenticatesUser | ||
{ | ||
Jwt = jwt, | ||
}); | ||
|
||
var criticalPlants = await plantService.GetCriticalPlants(user.UserEmail); | ||
socket.SendDto(new ServerSendsCriticalPlants | ||
{ | ||
Plants = criticalPlants | ||
}); | ||
|
||
var getUserDto = new GetUserDto | ||
{ | ||
UserEmail = user.UserEmail, | ||
Username = user.UserName, | ||
}; | ||
|
||
if (!string.IsNullOrEmpty(user.BlobUrl)) | ||
{ | ||
getUserDto.BlobUrl = blobStorageService.GenerateSasUri(user.BlobUrl, false); | ||
} | ||
|
||
socket.SendDto(new ServerSendsUserInfo | ||
{ | ||
GetUserDto = getUserDto | ||
}); | ||
|
||
var allCollections = await collectionsService.GetCollectionsForUser(user.UserEmail); | ||
socket.SendDto(new ServerSendsAllCollections | ||
{ | ||
Collections = allCollections.ToList() | ||
}); | ||
|
||
var stats = await statsService.GetStats(user.UserEmail); | ||
socket.SendDto(new ServerSendsStats | ||
{ | ||
Stats = stats | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters