Skip to content

Commit

Permalink
Adding video call (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanenshi committed Jan 5, 2025
1 parent 533324e commit f5bd0e0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .idea/.idea.Chat/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Api/Endpoints/V1/Room/Call/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Domain.Entities;
using Domain.Repositories;
using Domain.Services;
using Google.Apis.Util;
using Infrastructure.Models;
using Infrastructure.Services;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -61,6 +62,7 @@ await notificationService.SendCallSignalAsync(
);

room.VideoCall = new();
room.VideoCall.CalledAt = DateTime.UtcNow;
room.VideoCall.Beat();
room.VideoCall.Attenders =
[
Expand Down
4 changes: 4 additions & 0 deletions src/Api/Endpoints/V1/Room/Call/Put.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Domain.Services;
using Infrastructure.Models;
using Infrastructure.Services;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;

namespace Api.Endpoints.V1.Room.Call;
Expand Down Expand Up @@ -41,6 +42,9 @@ private static async Task<IResult> Handler(
if (!room.IsAttender(currentUserId))
return Results.Forbid();

if (!room.VideoCall.IsAlive())
return Results.Ok();

var token = agoraService.GenerateToken(id);
var callSignal = new CallSignalModel
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/RoomEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class VideoCallDataModel
{
[JsonPropertyName("attenders")] public List<VideoCallAttenderDataModel> Attenders { get; set; } = new();

[JsonPropertyName("calledAt")] public DateTime CalledAt { get; set; } = DateTime.UtcNow;
[JsonPropertyName("calledAt")] public DateTime CalledAt { get; set; }

[JsonPropertyName("answeredAt")] public DateTime? AnsweredAt { get; set; }

Expand Down

0 comments on commit f5bd0e0

Please sign in to comment.