add rate limits
This commit is contained in:
parent
e15ce6ba8b
commit
c523d40342
4 changed files with 71 additions and 6 deletions
|
|
@ -97,7 +97,7 @@ public class Requests
|
|||
return Encoding.UTF8.GetString(await Fs.ReadFile(path));
|
||||
}
|
||||
|
||||
public static async Task<string> UpdateDmKey(string id, string dmId, string key)
|
||||
public static async Task<string> UpdateDmKey(string id, string dmId, string key) //nie powinno byc takich rzeczy jak ta, jak juz powinnismy tworzyc nowy klucz, np. 1 i pozniej w wiadomosci wpisywac Message.key = "1" i nim szyfrowac
|
||||
{
|
||||
if (!await IsMemberOfDm(id, dmId))
|
||||
{
|
||||
|
|
@ -414,7 +414,7 @@ public class Requests
|
|||
if (memberId == id)
|
||||
{
|
||||
await Account.Utils.UpdateUserDm(memberId, dmId, "true", msg.timestamp);
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}");
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}:read");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -430,7 +430,7 @@ public class Requests
|
|||
{
|
||||
userLock.Release();
|
||||
}
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}");
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}:unread");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -459,8 +459,10 @@ public class Requests
|
|||
);
|
||||
|
||||
if (msg.author != id) return "error:forbidden";
|
||||
if (msg.type == "larp.redacted") return "error:message.already.deleted";
|
||||
|
||||
msg.type = "larp.redacted";
|
||||
msg.reactions = "";
|
||||
msg.content = "{blah(larp.redacted)}";
|
||||
msg.attachment = "";
|
||||
msg.key = "";
|
||||
|
|
@ -474,7 +476,7 @@ public class Requests
|
|||
string memberId = Account.Utils.GetValidIdOrZero(memberWD);
|
||||
if (isLocal)
|
||||
{
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}");
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}:update");
|
||||
}
|
||||
}
|
||||
return "success:message.deleted";
|
||||
|
|
@ -501,6 +503,8 @@ public class Requests
|
|||
AppJsonSerializerContext.Default.Message
|
||||
);
|
||||
|
||||
if (msg.type == "larp.redacted") return "error:message.already.deleted";
|
||||
|
||||
msg.reactions = reactions ?? "";
|
||||
|
||||
await Fs.WriteFile(msgPath, Encoding.UTF8.GetBytes(JsonSerializer.Serialize(msg, AppJsonSerializerContext.Default.Message)));
|
||||
|
|
@ -512,7 +516,7 @@ public class Requests
|
|||
string memberId = Account.Utils.GetValidIdOrZero(memberWD);
|
||||
if (isLocal)
|
||||
{
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}");
|
||||
await Utils.Utils.SendWsMessage(memberId, $"dm_message:{dmId}:update");
|
||||
}
|
||||
}
|
||||
return "success:message.reacted";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue