Commit 6395f829 authored by Christopher Davis's avatar Christopher Davis 🌱
Browse files

Update used API endpoints to the current spec

Updates the key upload endpoint and moves it into it's
own module as a constant.

Closes #24
parent bfae30ed
Pipeline #76802 failed with stages
in 3 minutes and 19 seconds
......@@ -94,7 +94,7 @@ This is a HTTP request, that is to be forwarded by the client.
:details: HTTP request type, followed by the URL for the request,
written in the same style as URLs in the Matrix specification.
They are seperated with a space, for example for uploading device
keys this would be ``POST /_matrix/client/unstable/keys/upload``.
keys this would be ``POST /_matrix/client/r0/keys/upload``.
:body: JSON data for the request
:blocker_id: Some
......
......@@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::blocker::{BlockerManager, Participant};
use crate::endpoints;
use crate::json_objects::{device::SignedDeviceKeys, olm::OlmIdentityKeys};
use crate::metaolm::Metaolm;
use crate::packet::*;
......@@ -198,7 +199,7 @@ impl MetaolmBuilder {
let register_request = M2CPacket {
header: M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string(),
endpoints::UPLOAD_KEYS.to_string(),
),
body: serde_json::to_string(&device_keys).unwrap(),
blocker_id: Some(register_request_blocker),
......
// Metaolm - a stand-alone module for E2EE in the Matrix protocol
// Copyright 2019 Christopher Davis <brainblasted@disroot.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
pub static UPLOAD_KEYS: &'static str = "/_matrix/client/r0/keys/upload";
......@@ -17,6 +17,7 @@
pub mod blocker;
pub mod builder;
pub mod crypto_routines;
pub mod endpoints;
pub mod json_objects;
pub mod metaolm;
pub mod otk_replenisher;
......
......@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::endpoints;
use crate::json_objects::otk::{OneTimeKeys, SignedOneTimeKey};
use crate::packet::{HTTPReqType, M2CPacket, M2CPacketType};
use olm_rs::account::OlmAccount;
......@@ -94,7 +95,7 @@ impl OTKReplenisher {
Some(M2CPacket {
header: M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string(),
endpoints::UPLOAD_KEYS.to_string(),
),
body: serde_json::to_string(&signed_otks).unwrap(),
blocker_id: Some(blocker_id),
......
......@@ -17,6 +17,8 @@
/// Object used for the client to communicate with
/// the Metaolm module, but not the other way around -
/// that's what `M2CCommObject` is for.
use crate::endpoints;
pub struct C2MPacket {
pub header: C2MPacketType,
pub body: String,
......@@ -97,7 +99,7 @@ impl M2CPacket {
M2CPacket {
header: M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string(),
endpoints::UPLOAD_KEYS.to_string(),
),
body: String::from("{}"),
blocker_id: Some(blocker_id),
......
......@@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use metaolm::builder::MetaolmBuilder;
use metaolm::endpoints;
use metaolm::json_objects::device::SignedDeviceKeys;
use metaolm::json_objects::event::*;
use metaolm::json_objects::misc::MegolmPlaintextPacketBody;
......@@ -93,7 +94,7 @@ fn empty_init() {
assert_eq!(
M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string()
endpoints::UPLOAD_KEYS.to_string()
),
device_keys_req.header
);
......@@ -121,7 +122,7 @@ fn empty_init() {
assert_eq!(
M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string()
endpoints::UPLOAD_KEYS.to_string()
),
otk_count_req.header
);
......@@ -141,7 +142,7 @@ fn empty_init() {
assert_eq!(
M2CPacketType::HTTPReq(
HTTPReqType::Post,
"/_matrix/client/unstable/keys/upload".to_string()
endpoints::UPLOAD_KEYS.to_string()
),
otk_upload_req.header
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment