Skip to content

Commit

Permalink
fix(pr: issue-293): update chatmanager for smalltalk api
Browse files Browse the repository at this point in the history
Merge pull request #294 from live-dev999/live-dev999/issue293
  • Loading branch information
live-dev999 committed Apr 9, 2022
2 parents 8b9fd4a + da7eaa8 commit db7fda1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/Services/smalltalk/O2NextGen.SmallTalk.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using O2NextGen.SmallTalk.Api.Helpers;
using System.Threading.Tasks;

namespace O2NextGen.SmallTalk.Api
{
Expand Down Expand Up @@ -32,7 +33,19 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.Use(async (context, next) =>
{
context.Response.OnStarting(() =>
{
context.Response.Headers.Add("X-Power-By", "O2NextGen: SmallTalk Api");
return Task.CompletedTask;
});
await next.Invoke();
});

app.UseMvc();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public async Task<ChatMessageModel> AddMessage(long sessionId,ChatMessageModel c
{
var chatMessage = Creator<ChatMessageModel>.CreateObject();
chatMessage.Message = chatMessageModel.Message;

chatMessage.SenderId = chatMessageModel.SenderId;
chatMessage.RecipientId = chatMessageModel.RecipientId;

ChatSessionModel chatSession = null;
//Checking if a session exists or not
Expand Down Expand Up @@ -60,6 +61,11 @@ public async Task<IReadOnlyCollection<ChatMessageModel>> GetMessages(long idSess
return result;
}

public Task GetSession(long sessionId, CancellationToken ct)
{
throw new System.NotImplementedException();
}

public Task RemoveMessageAsync(long sessionId, long id, CancellationToken ct)
{
throw new System.NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public async Task<ChatSessionModel> AddSessionAsync(ChatSessionModel chatSession
return await Task.FromResult(chatSession);
}

public async Task<bool> ExistSessionAsync(long sessionId,CancellationToken ct)
public async Task<bool> ExistSessionAsync(long sessionId, CancellationToken ct)
{
var result = Sessions.Any(_ => _.Id == sessionId);
return await Task.FromResult<bool>(result);
}

public async Task<ChatSessionModel> GetSessionAsync(long sessionId,CancellationToken ct)
public async Task<ChatSessionModel> GetSessionAsync(long sessionId, CancellationToken ct)
{
var result = Sessions.Single(_ => _.Id == sessionId);
return await Task.FromResult(result);
Expand Down

0 comments on commit db7fda1

Please sign in to comment.