🐛 Fixes of accounts mentioned messages unable to send
This commit is contained in:
@@ -57,6 +57,19 @@ public class AccountServiceGrpc(
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<GetAccountBatchResponse> LookupAccountBatch(LookupAccountBatchRequest request, ServerCallContext context)
|
||||||
|
{
|
||||||
|
var accountNames = request.Names.ToList();
|
||||||
|
var accounts = await _db.Accounts
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(a => accountNames.Contains(a.Name))
|
||||||
|
.Include(a => a.Profile)
|
||||||
|
.ToListAsync();
|
||||||
|
var response = new GetAccountBatchResponse();
|
||||||
|
response.Accounts.AddRange(accounts.Select(a => a.ToProtoValue()));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task<ListAccountsResponse> ListAccounts(ListAccountsRequest request,
|
public override async Task<ListAccountsResponse> ListAccounts(ListAccountsRequest request,
|
||||||
ServerCallContext context)
|
ServerCallContext context)
|
||||||
{
|
{
|
||||||
|
@@ -218,6 +218,7 @@ service AccountService {
|
|||||||
// Account Operations
|
// Account Operations
|
||||||
rpc GetAccount(GetAccountRequest) returns (Account) {}
|
rpc GetAccount(GetAccountRequest) returns (Account) {}
|
||||||
rpc GetAccountBatch(GetAccountBatchRequest) returns (GetAccountBatchResponse) {}
|
rpc GetAccountBatch(GetAccountBatchRequest) returns (GetAccountBatchResponse) {}
|
||||||
|
rpc LookupAccountBatch(LookupAccountBatchRequest) returns (GetAccountBatchResponse) {}
|
||||||
rpc ListAccounts(ListAccountsRequest) returns (ListAccountsResponse) {}
|
rpc ListAccounts(ListAccountsRequest) returns (ListAccountsResponse) {}
|
||||||
|
|
||||||
// Profile Operations
|
// Profile Operations
|
||||||
@@ -292,6 +293,10 @@ message GetAccountBatchRequest {
|
|||||||
repeated string id = 1; // Account ID to retrieve
|
repeated string id = 1; // Account ID to retrieve
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message LookupAccountBatchRequest {
|
||||||
|
repeated string names = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message GetAccountBatchResponse {
|
message GetAccountBatchResponse {
|
||||||
repeated Account accounts = 1; // List of accounts
|
repeated Account accounts = 1; // List of accounts
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,8 @@ public partial class ChatController(
|
|||||||
AppDatabase db,
|
AppDatabase db,
|
||||||
ChatService cs,
|
ChatService cs,
|
||||||
ChatRoomService crs,
|
ChatRoomService crs,
|
||||||
FileService.FileServiceClient files
|
FileService.FileServiceClient files,
|
||||||
|
AccountService.AccountServiceClient accounts
|
||||||
) : ControllerBase
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
public class MarkMessageReadRequest
|
public class MarkMessageReadRequest
|
||||||
@@ -213,8 +214,14 @@ public partial class ChatController(
|
|||||||
.ToList();
|
.ToList();
|
||||||
if (mentioned.Count > 0)
|
if (mentioned.Count > 0)
|
||||||
{
|
{
|
||||||
|
var queryRequest = new LookupAccountBatchRequest();
|
||||||
|
queryRequest.Names.AddRange(mentioned);
|
||||||
|
var queryResponse = (await accounts.LookupAccountBatchAsync(queryRequest)).Accounts;
|
||||||
|
var mentionedId = queryResponse
|
||||||
|
.Select(a => Guid.Parse(a.Id))
|
||||||
|
.ToList();
|
||||||
var mentionedMembers = await db.ChatMembers
|
var mentionedMembers = await db.ChatMembers
|
||||||
.Where(m => mentioned.Contains(m.Account.Name))
|
.Where(m => mentionedId.Contains(m.AccountId))
|
||||||
.Select(m => m.Id)
|
.Select(m => m.Id)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
message.MembersMentioned = mentionedMembers;
|
message.MembersMentioned = mentionedMembers;
|
||||||
|
Reference in New Issue
Block a user