Claire
4 years ago
33 changed files with 566 additions and 19 deletions
diff.bin_not_shown
diff.bin_not_shown
diff.bin_not_shown
diff.bin_not_shown
@ -1,8 +1,10 @@ |
|||||||
{ |
{ |
||||||
"version": 2, |
"version": 2, |
||||||
"dgSpecHash": "/And0b5Fmn9KmvRqoYIwpU+aYPZ3tOpcWNW71la94v+grVFCDobR3JbJQwG/7g1BRYhNza7okd7X7+ntHOryfw==", |
"dgSpecHash": "8K9QsUKHtNC7PQ873ayC0GHP0lzCog8MTKCNWMZpyzUOnHRnzzR9zoCKZj29McVjauf8VButj3vnkK+05EZTuA==", |
||||||
"success": true, |
"success": true, |
||||||
"projectFilePath": "D:\\Source\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetCmd\\MatrixDotNetCmd.csproj", |
"projectFilePath": "D:\\Source\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetCmd\\MatrixDotNetCmd.csproj", |
||||||
"expectedPackageFiles": [], |
"expectedPackageFiles": [ |
||||||
|
"C:\\Users\\Claire\\.nuget\\packages\\newtonsoft.json\\12.0.3\\newtonsoft.json.12.0.3.nupkg.sha512" |
||||||
|
], |
||||||
"logs": [] |
"logs": [] |
||||||
} |
} |
@ -0,0 +1,132 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixApis |
||||||
|
{ |
||||||
|
public static Dictionary<string, string> Server = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "discovery", "/.well-known/matrix/client" }, |
||||||
|
{ "versions", "/_matrix/client/versions" }, |
||||||
|
{ "capabilities", "/_matrix/client/r0/capabilities" }, |
||||||
|
{ "whois", "/_matrix/client/r0/admin/whois/{uid}" }, |
||||||
|
{ "search", "/_matrix/client/r0/search" }, |
||||||
|
{ "usersearch", "/_matrix/client/r0/user_directory/search" }, |
||||||
|
{ "roomlist", "/_matrix/client/r0/publicRooms" }, |
||||||
|
{ "managerooms", "/_matrix/client/r0/directory/list/appservice/{networkId}/{roomId}" }, |
||||||
|
{ "upgraderoom", "/_matrix/client/r0/rooms/{roomId}/upgrade" }, |
||||||
|
{ "openid", "/_matrix/client/r0/user/{userId}/openid/request_token" }, |
||||||
|
{ "voip", "/_matrix/client/r0/voip/turnServer" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> Key = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "latest", "/_matrix/client/r0/keys/changes" }, |
||||||
|
{ "claim", "/_matrix/client/r0/keys/claim" }, |
||||||
|
{ "download", "/_matrix/client/r0/keys/query" }, |
||||||
|
{ "upload", "/_matrix/client/r0/keys/upload" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> Device = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "manage", "/_matrix/client/r0/devices" }, |
||||||
|
{ "multidelete", "/_matrix/client/r0/delete_devices" }, |
||||||
|
{ "send", "/_matrix/client/r0/sendToDevice/{eventType}/{txnId}" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> Media = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "config", "/_matrix/media/r0/config" }, |
||||||
|
{ "save", "/_matrix/media/r0/download/{serverName}/{mediaId}" }, |
||||||
|
{ "saveas", "/_matrix/media/r0/download/{serverName}/{mediaId}/{fileName}" }, |
||||||
|
{ "preview", "/_matrix/media/r0/preview_url" }, |
||||||
|
{ "thumb", "/_matrix/media/r0/thumbnail/{serverName}/{mediaId}" }, |
||||||
|
{ "upload", "/_matrix/media/r0/upload" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> Notifier = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "notifiers", "/_matrix/client/r0/notifications" }, |
||||||
|
{ "pushers", "/_matrix/client/r0/pushers" }, |
||||||
|
{ "set", "/_matrix/client/r0/pushers/set" }, |
||||||
|
{ "rules", "/_matrix/client/r0/pushrules/" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> NotifierRule = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "manage", "/_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}" }, |
||||||
|
{ "actions", "/_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions" }, |
||||||
|
{ "toggle", "/_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> User = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "thirdparty", "/_matrix/client/r0/account/3pid" }, |
||||||
|
{ "deactivate", "/_matrix/client/r0/account/deactivate" }, |
||||||
|
{ "password", "/_matrix/client/r0/account/password" }, |
||||||
|
{ "register", "/_matrix/client/r0/register" }, |
||||||
|
{ "whoami", "/_matrix/client/r0/account/whoami" }, |
||||||
|
{ "profile", "/_matrix/client/r0/profile/{userId}" }, |
||||||
|
{ "avatar", "/_matrix/client/r0/profile/{userId}/avtatar_url" }, |
||||||
|
{ "displayname", "/_matrix/client/r0/profile/{userId}/displayname" }, |
||||||
|
{ "extrainfo", "/_matrix/client/r0/user/{userId}/account_data/{type}" }, |
||||||
|
{ "eventfilter", "/_matrix/client/r0/user/{userId}/filter" }, |
||||||
|
{ "rooms", "/_matrix/client/r0/joined_rooms" }, |
||||||
|
{ "login", "/_matrix/client/r0/login" }, |
||||||
|
{ "logout", "/_matrix/client/r0/logout" }, |
||||||
|
{ "status", "/_matrix/client/r0/presence/{userId}/status" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> UserRoom = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "extrainfo", "/_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}" }, |
||||||
|
{ "tags", "/_matrix/client/r0/user/{userId}/rooms/{roomId}/tags" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> Room = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "create", "/_matrix/client/r0/createRoom" }, |
||||||
|
{ "aliases", "/_matrix/client/r0/rooms/{roomId}/aliases" }, |
||||||
|
{ "active", "/_matrix/client/r0/rooms/{roomId}/joined_members" }, |
||||||
|
{ "members", "/_matrix/client/r0/rooms/{roomId}/members" }, |
||||||
|
{ "messages", "/_matrix/client/r0/rooms/{roomId}/messages" }, |
||||||
|
{ "join", "/_matrix/client/r0/join/{roomIdOrAlias}" }, |
||||||
|
{ "ban", "/_matrix/client/r0/rooms/{roomId}/ban" }, |
||||||
|
{ "forget", "/_matrix/client/r0/rooms/{roomId}/forget" }, |
||||||
|
{ "invite", "/_matrix/client/r0/rooms/{roomId}/invite" }, |
||||||
|
{ "idjoin", "/_matrix/client/r0/rooms/{roomId}/join" }, |
||||||
|
{ "kick", "/_matrix/client/r0/rooms/{roomId}/kick" }, |
||||||
|
{ "leave", "/_matrix/client/r0/rooms/{roomId}/leave" }, |
||||||
|
{ "unban", "/_matrix/client/r0/rooms/{roomId}/unban" }, |
||||||
|
{ "marker", "/_matrix/client/r0/rooms/{roomId}/read_markers" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> RoomEvent = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "context", "/_matrix/client/r0/rooms/{roomId}/context/{eventId}" }, |
||||||
|
{ "event", "/_matrix/client/r0/rooms/{roomId}/event/{eventId}" }, |
||||||
|
{ "receipt", "/_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}" }, |
||||||
|
{ "redact", "/_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}" }, |
||||||
|
{ "send", "/_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}" }, |
||||||
|
{ "typing", "/_matrix/client/r0/rooms/{roomId}/typing/{userId}" }, |
||||||
|
{ "flag", "/_matrix/client/r0/rooms/{roomId}/report/{eventId}" } |
||||||
|
}; |
||||||
|
|
||||||
|
public static Dictionary<string, string> RoomState = new Dictionary<string, string>() |
||||||
|
{ |
||||||
|
{ "list", "/_matrix/client/r0/rooms/{roomId}/state" }, |
||||||
|
{ "state", "/_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}" } |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
class HotDamn |
||||||
|
{ |
||||||
|
public void testfunc() |
||||||
|
{ |
||||||
|
// the avatar |
||||||
|
string Avatar = MatrixApis.User["avatar"]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,9 +0,0 @@ |
|||||||
using System; |
|
||||||
|
|
||||||
namespace MatrixDotNetLib |
|
||||||
{ |
|
||||||
public class MatrixClient |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,28 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixError |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the error code (required) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("errcode")] |
||||||
|
public string ErrorCode { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the friendly error message (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("error")] |
||||||
|
public string ErrorMessage { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the delay in milliseconds (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("retry_after_ms")] |
||||||
|
public Int32 RetryDelay { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixLoginFlows |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the array of available login types |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("flows")] |
||||||
|
public MatrixLoginType[] LoginFlows { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixLoginIdentifier |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the login identifier type (required) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("type")] |
||||||
|
public string IdType { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the username (required if IdType is m.id.user) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("user")] |
||||||
|
public string User { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Runtime.CompilerServices; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixLoginRequest |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the client device ID (optional, auto-generated if null) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("device_id")] |
||||||
|
public string DeviceId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets user identifier as string (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("identifier")] |
||||||
|
public MatrixLoginIdentifier Identifier { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the device display name (optional, ignored if device is known) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("initial_device_display_name")] |
||||||
|
public string DeviceName { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the password (required if type=m.login.password) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("password")] |
||||||
|
public string Password { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the login token (required if type=m.login.token) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("token")] |
||||||
|
public string Token { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Sets the static dictionary of login types (required) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("type")] |
||||||
|
public string LoginType { get; set; } |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixLoginResponse |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the access token (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("access_token")] |
||||||
|
public string Token { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the device ID (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("device_id")] |
||||||
|
public string DeviceId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the user ID (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("user_id")] |
||||||
|
public string UserId { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets client configuration (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("well_known")] |
||||||
|
public MatrixUserServers KnownServers { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixLoginType |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the login type |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("type")] |
||||||
|
public string LoginType { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Net; |
||||||
|
using System.Net.Http; |
||||||
|
using System.Net.Http.Headers; |
||||||
|
using System.Reflection.Metadata.Ecma335; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixSessionManager |
||||||
|
{ |
||||||
|
public MatrixLoginResponse Login(string server, string user, string pass, string device = "") |
||||||
|
{ |
||||||
|
MatrixLoginIdentifier userId = new MatrixLoginIdentifier() |
||||||
|
{ |
||||||
|
IdType = "m.id.user", |
||||||
|
User = user |
||||||
|
}; |
||||||
|
|
||||||
|
MatrixLoginRequest theRequest = new MatrixLoginRequest() |
||||||
|
{ |
||||||
|
Password = pass, |
||||||
|
Identifier = userId, |
||||||
|
LoginType = "m.login.password" |
||||||
|
}; |
||||||
|
|
||||||
|
if (device.Length > 0) |
||||||
|
{ |
||||||
|
theRequest.DeviceId = device; |
||||||
|
} |
||||||
|
|
||||||
|
// create a web request |
||||||
|
string loginUrl = "https://" + server + MatrixApis.User["login"]; |
||||||
|
|
||||||
|
// serialize object into JSON |
||||||
|
string requestJson = JsonConvert.SerializeObject(theRequest); |
||||||
|
|
||||||
|
HttpContent requestContent = new StringContent(requestJson, Encoding.UTF8, "application/json"); |
||||||
|
|
||||||
|
HttpClient client = new HttpClient(); |
||||||
|
client.BaseAddress = new Uri(loginUrl); |
||||||
|
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
||||||
|
|
||||||
|
HttpResponseMessage responseMessage = client.PostAsync(loginUrl, requestContent).Result; |
||||||
|
string responseString = responseMessage.Content.ReadAsStringAsync().Result; |
||||||
|
|
||||||
|
MatrixLoginResponse response = JsonConvert.DeserializeObject<MatrixLoginResponse>(responseString); |
||||||
|
|
||||||
|
return response; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixUser |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets user id as a string |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("user_id")] |
||||||
|
public string userid { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets access token as a string |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("access_token")] |
||||||
|
public string token { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets home server as string |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("home_server")] |
||||||
|
public string server { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets device id as string (optional) |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("device_id")] |
||||||
|
public string deviceid { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixUserServer |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the server URL |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("base_url")] |
||||||
|
public string BaseUrl { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
using Newtonsoft.Json; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace MatrixDotNetLib |
||||||
|
{ |
||||||
|
public class MatrixUserServers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the home server |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("m.homeserver")] |
||||||
|
public MatrixUserServer HomeServer { get; set; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets or sets the identity server |
||||||
|
/// </summary> |
||||||
|
[JsonProperty("m.identity_server")] |
||||||
|
public MatrixUserServer IdentityServer { get; set; } |
||||||
|
} |
||||||
|
} |
diff.bin_not_shown
diff.bin_not_shown
diff.bin_not_shown
@ -1 +1 @@ |
|||||||
bebfa3bded4fe686bd663f099492d7164d88fe28 |
f16bca70409c8e2ae88277b1bedf2f151bb03767 |
||||||
|
diff.bin_not_shown
diff.bin_not_shown
diff.bin_not_shown
@ -1,8 +1,10 @@ |
|||||||
{ |
{ |
||||||
"version": 2, |
"version": 2, |
||||||
"dgSpecHash": "6v622xy25DE5lRrEgpsiWk2YtQjIi38nbMXINLdc/3QnYXSe1ti2zp/2q7CTNPT3u+UJEjyWV0GE4lClJkOjXg==", |
"dgSpecHash": "HSqSJqUuJZSv4YceApWKKSok/vyC24dgbjbsKNopZt2t8ILlKoApuI5ZMQ2Wm+AKO8PAKuY9eeR4/hEyKBtJIg==", |
||||||
"success": true, |
"success": true, |
||||||
"projectFilePath": "D:\\Source\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetLib.csproj", |
"projectFilePath": "D:\\Source\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetLib\\MatrixDotNetLib.csproj", |
||||||
"expectedPackageFiles": [], |
"expectedPackageFiles": [ |
||||||
|
"C:\\Users\\Claire\\.nuget\\packages\\newtonsoft.json\\12.0.3\\newtonsoft.json.12.0.3.nupkg.sha512" |
||||||
|
], |
||||||
"logs": [] |
"logs": [] |
||||||
} |
} |
Loading…
issues.context.reference_issue