Add "user/dm/invite/revoke" and "user/dm/invite/decline"
This commit is contained in:
parent
017eb2501b
commit
69ccfd3421
5 changed files with 158 additions and 32 deletions
|
|
@ -316,6 +316,29 @@ public class Requests
|
|||
|
||||
}
|
||||
|
||||
public static async Task NameToId(HttpContext context, Func<Task> next, IQueryCollection query)
|
||||
{
|
||||
if (!query.TryGetValue("u", out var username))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Utils.IsUserLocal(username, out string domain)) //federation
|
||||
{
|
||||
username = username.ToString().Split(":")[0];
|
||||
string remoteId = await Federation.Sender.GetUserId(username, domain);
|
||||
if (remoteId != "0" && !string.IsNullOrEmpty(remoteId))
|
||||
{
|
||||
await context.Response.WriteAsync(remoteId + $":{domain}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
username = username.ToString().Split(":")[0];
|
||||
|
||||
await context.Response.WriteAsync(await Utils.IdFromName(username) + $":{DOMAIN}");
|
||||
return;
|
||||
}
|
||||
|
||||
public static async Task IdToName(HttpContext context, Func<Task> next, IQueryCollection query)
|
||||
{
|
||||
if (!query.TryGetValue("id", out var id))
|
||||
|
|
@ -467,18 +490,16 @@ public class Requests
|
|||
|
||||
public static async Task GetUserPublicKey(HttpContext context, Func<Task> next, IQueryCollection query, StreamReader bodyReader)
|
||||
{
|
||||
if (!query.TryGetValue("u", out var username))
|
||||
if (!query.TryGetValue("id", out var idQuery))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Utils.IsUserLocal(username, out string domain)) //federation :(
|
||||
if (!Utils.IsUserLocal(idQuery, out string domain)) //federation :(
|
||||
{
|
||||
return;
|
||||
}
|
||||
username = username.ToString().Split(":")[0];
|
||||
|
||||
string id = await Utils.IdFromName(username);
|
||||
string id = idQuery.ToString().Split(":")[0];
|
||||
|
||||
Universal2String keys = JsonSerializer.Deserialize(
|
||||
await Utils.GetUserKeys(id),
|
||||
|
|
@ -490,21 +511,20 @@ public class Requests
|
|||
|
||||
public static async Task GetUserPublicStorageEntry(HttpContext context, Func<Task> next, IQueryCollection query, StreamReader bodyReader)
|
||||
{
|
||||
if (!query.TryGetValue("u", out var username))
|
||||
if (!query.TryGetValue("id", out var idQuery))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!query.TryGetValue("entry", out var entry))
|
||||
if (!query.TryGetValue("e", out var entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Utils.IsUserLocal(username, out string domain)) //federation :(
|
||||
|
||||
if (!Utils.IsUserLocal(idQuery, out string domain)) //federation :(
|
||||
{
|
||||
return;
|
||||
}
|
||||
username = username.ToString().Split(":")[0];
|
||||
|
||||
string id = await Utils.IdFromName(username);
|
||||
string id = idQuery.ToString().Split(":")[0];
|
||||
|
||||
byte[] entryByte = await Utils.GetUserPublicStorageEntry(id, entry);
|
||||
|
||||
|
|
@ -589,6 +609,18 @@ public class Requests
|
|||
await Room.Requests.DmInvite(id, serializedBody.string2)
|
||||
, password));
|
||||
break;
|
||||
case "user/dm/invite/revoke":
|
||||
await context.Response.WriteAsync(
|
||||
Encryption.Encryption.EncryptString(
|
||||
await Room.Requests.DmInviteRevoke(id, serializedBody.string2)
|
||||
, password));
|
||||
break;
|
||||
case "user/dm/invite/decline":
|
||||
await context.Response.WriteAsync(
|
||||
Encryption.Encryption.EncryptString(
|
||||
await Room.Requests.DmInviteDecline(id, serializedBody.string2)
|
||||
, password));
|
||||
break;
|
||||
case "user/dm/create":
|
||||
await context.Response.WriteAsync(
|
||||
Encryption.Encryption.EncryptString(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue