Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
wsq003 committed Apr 12, 2022
1 parent 5e9f760 commit 4faf8cb
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ public async Task<MdtResp> Handle(MdtRequest<ChannelMemberCmd> req, Cancellation
var old = await _conn.FirstOrDefaultAsync(x => x.channelID == model.channelID && x.memberID == model.memberID);
if (old != null)
{
return (false, "dup");
return (false, "dup member already exist");
}
var old2 = await _conn.FirstOrDefaultAsync(x => x.cmID == model.cmID);
if (old2 != null)
{
return (false, $"dup cmID: {model.cmID}");
}
var count = await _conn.CountAsync(x => x.channelID == model.channelID);
if (count > maxChannelMemberCount)
{
return (false, $"each channel can have {maxChannelMemberCount} members at most");
}

await _conn.UpsertAsync(x => x.channelID == model.channelID && x.userID == model.userID, model);
await _conn.UpsertAsync(x => x.channelID == model.channelID && x.memberID == model.memberID, model);

return (true, "");
}
Expand Down

0 comments on commit 4faf8cb

Please sign in to comment.