Compare commits
84 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
9b57c89df6 | 4 years ago |
|
|
34d3f74f36 | 4 years ago |
|
|
11a21fc136 | 4 years ago |
|
|
0183d003d0 | 4 years ago |
|
|
f712455047 | 4 years ago |
|
|
58ea081762 | 4 years ago |
|
|
bffddbd487 | 4 years ago |
|
|
41fef1da64 | 4 years ago |
|
|
892a0525f2 | 4 years ago |
|
|
1fc616320a | 4 years ago |
|
|
14a178d783 | 4 years ago |
|
|
339a26f56c | 4 years ago |
|
|
ca724b6340 | 4 years ago |
|
|
9bfc7b34b6 | 4 years ago |
|
|
afa5d449c6 | 4 years ago |
|
|
2fff720df3 | 4 years ago |
|
|
da00f611e9 | 4 years ago |
|
|
9fccbb014a | 4 years ago |
|
|
109892b4b7 | 4 years ago |
|
|
24a835647c | 4 years ago |
|
|
c4bce1d0c7 | 4 years ago |
|
|
9b63708685 | 4 years ago |
|
|
86177faae7 | 4 years ago |
|
|
2a749c1e99 | 4 years ago |
|
|
5ae753b2e7 | 4 years ago |
|
|
743bdbe961 | 4 years ago |
|
|
d5d25fb064 | 4 years ago |
|
|
8087a26a35 | 4 years ago |
|
|
bbe16f8467 | 4 years ago |
|
|
50f931a2fd | 4 years ago |
|
|
1541b93f45 | 4 years ago |
|
|
ccf501a420 | 4 years ago |
|
|
6f70beb78c | 4 years ago |
|
|
259fc580ca | 4 years ago |
|
|
55d78b1914 | 4 years ago |
|
|
484a044b50 | 4 years ago |
|
|
2264a5f945 | 4 years ago |
|
|
e88929e154 | 4 years ago |
|
|
d996d1b0e6 | 4 years ago |
|
|
dc8bc4a880 | 4 years ago |
|
|
87694f4369 | 4 years ago |
|
|
335027e739 | 4 years ago |
|
|
0ccda5f1c7 | 4 years ago |
|
|
9082a531c9 | 4 years ago |
|
|
91afa1e0e0 | 4 years ago |
|
|
f2ef5677e0 | 4 years ago |
|
|
1c4d9af586 | 4 years ago |
|
|
09895a20c8 | 4 years ago |
|
|
636db8cfaa | 4 years ago |
|
|
6bc8fb2ae7 | 4 years ago |
|
|
5b23d3d06e | 4 years ago |
|
|
47f3263396 | 4 years ago |
|
|
d38f9b5f01 | 4 years ago |
|
|
fa616342b6 | 4 years ago |
|
|
34fa7fee05 | 4 years ago |
|
|
e8d998cedf | 4 years ago |
|
|
565fe3a7dd | 4 years ago |
|
|
5c02dc7830 | 4 years ago |
|
|
159e22e450 | 4 years ago |
|
|
ab472e9b7c | 4 years ago |
|
|
31264e3d1d | 4 years ago |
|
|
422bd09e32 | 4 years ago |
|
|
b64538c6f1 | 4 years ago |
|
|
178451e9b5 | 4 years ago |
|
|
583a966f6e | 4 years ago |
|
|
cbee7fe111 | 4 years ago |
|
|
d68c93b5fa | 4 years ago |
|
|
979ec6b4fa | 4 years ago |
|
|
910ad7fed1 | 4 years ago |
|
|
2c8412fe58 | 4 years ago |
|
|
06b0c9267f | 4 years ago |
|
|
00927a7ce3 | 4 years ago |
|
|
4aacafc298 | 4 years ago |
|
|
23c5ec8099 | 4 years ago |
|
|
562a2524d7 | 4 years ago |
|
|
51245d34f1 | 4 years ago |
|
|
4a773a1096 | 4 years ago |
|
|
5821b8e705 | 4 years ago |
|
|
0737bc021f | 4 years ago |
|
|
487046571c | 4 years ago |
|
|
2d242523fc | 4 years ago |
|
|
bbe36810ec | 4 years ago |
|
|
a449b1d73f | 4 years ago |
|
|
71341ea05a | 4 years ago |
66 changed files with 2477 additions and 2498 deletions
@ -0,0 +1,84 @@ |
|||||||
|
use crate::{ |
||||||
|
database::{admin::AdminCommand, DatabaseGuard}, |
||||||
|
ConduitResult, Error, Ruma, |
||||||
|
}; |
||||||
|
use ruma::{ |
||||||
|
api::client::{error::ErrorKind, r0::room::report_content}, |
||||||
|
events::room::message, |
||||||
|
int, |
||||||
|
}; |
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")] |
||||||
|
use rocket::{http::RawStr, post}; |
||||||
|
|
||||||
|
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
|
||||||
|
///
|
||||||
|
/// Reports an inappropriate event to homeserver admins
|
||||||
|
///
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin", |
||||||
|
post("/_matrix/client/r0/rooms/<_>/report/<_>", data = "<body>") |
||||||
|
)] |
||||||
|
#[tracing::instrument(skip(db, body))] |
||||||
|
pub async fn report_event_route( |
||||||
|
db: DatabaseGuard, |
||||||
|
body: Ruma<report_content::Request<'_>>, |
||||||
|
) -> ConduitResult<report_content::Response> { |
||||||
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); |
||||||
|
|
||||||
|
let pdu = match db.rooms.get_pdu(&body.event_id)? { |
||||||
|
Some(pdu) => pdu, |
||||||
|
_ => { |
||||||
|
return Err(Error::BadRequest( |
||||||
|
ErrorKind::InvalidParam, |
||||||
|
"Invalid Event ID", |
||||||
|
)) |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
if body.score > int!(0) || body.score < int!(-100) { |
||||||
|
return Err(Error::BadRequest( |
||||||
|
ErrorKind::InvalidParam, |
||||||
|
"Invalid score, must be within 0 to -100", |
||||||
|
)); |
||||||
|
}; |
||||||
|
|
||||||
|
if body.reason.chars().count() > 250 { |
||||||
|
return Err(Error::BadRequest( |
||||||
|
ErrorKind::InvalidParam, |
||||||
|
"Reason too long, should be 250 characters or fewer", |
||||||
|
)); |
||||||
|
}; |
||||||
|
|
||||||
|
db.admin.send(AdminCommand::SendMessage( |
||||||
|
message::RoomMessageEventContent::text_html( |
||||||
|
format!( |
||||||
|
"Report received from: {}\n\n\ |
||||||
|
Event ID: {}\n\ |
||||||
|
Room ID: {}\n\ |
||||||
|
Sent By: {}\n\n\ |
||||||
|
Report Score: {}\n\ |
||||||
|
Report Reason: {}", |
||||||
|
sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason |
||||||
|
), |
||||||
|
format!( |
||||||
|
"<details><summary>Report received from: <a href=\"https://matrix.to/#/{0}\">{0}\
|
||||||
|
</a></summary><ul><li>Event Info<ul><li>Event ID: <code>{1}</code>\ |
||||||
|
<a href=\"https://matrix.to/#/{2}/{1}\">🔗</a></li><li>Room ID: <code>{2}</code>\
|
||||||
|
</li><li>Sent By: <a href=\"https://matrix.to/#/{3}\">{3}</a></li></ul></li><li>\
|
||||||
|
Report Info<ul><li>Report Score: {4}</li><li>Report Reason: {5}</li></ul></li>\ |
||||||
|
</ul></details>", |
||||||
|
sender_user, |
||||||
|
pdu.event_id, |
||||||
|
pdu.room_id, |
||||||
|
pdu.sender, |
||||||
|
body.score, |
||||||
|
RawStr::new(&body.reason).html_escape() |
||||||
|
), |
||||||
|
), |
||||||
|
)); |
||||||
|
|
||||||
|
db.flush()?; |
||||||
|
|
||||||
|
Ok(report_content::Response {}.into()) |
||||||
|
} |
||||||
@ -1,101 +0,0 @@ |
|||||||
const puppeteer = require('puppeteer'); |
|
||||||
|
|
||||||
run().then(() => console.log('Done')).catch(error => { |
|
||||||
console.error("Registration test failed."); |
|
||||||
console.error("There might be a screenshot of the failure in the artifacts.\n"); |
|
||||||
console.error(error); |
|
||||||
process.exit(111); |
|
||||||
}); |
|
||||||
|
|
||||||
async function run() { |
|
||||||
|
|
||||||
const elementUrl = process.argv[process.argv.length - 2]; |
|
||||||
console.debug("Testing registration with ElementWeb hosted at "+ elementUrl); |
|
||||||
|
|
||||||
const homeserverUrl = process.argv[process.argv.length - 1]; |
|
||||||
console.debug("Homeserver url: "+ homeserverUrl); |
|
||||||
|
|
||||||
const username = "testuser" + String(Math.floor(Math.random() * 100000)); |
|
||||||
const password = "testpassword" + String(Math.floor(Math.random() * 100000)); |
|
||||||
console.debug("Testuser for this run:\n User: " + username + "\n Password: " + password); |
|
||||||
|
|
||||||
const browser = await puppeteer.launch({ |
|
||||||
headless: true, args: [ |
|
||||||
"--no-sandbox" |
|
||||||
] |
|
||||||
}); |
|
||||||
|
|
||||||
const page = await browser.newPage(); |
|
||||||
await page.goto(elementUrl); |
|
||||||
|
|
||||||
await page.screenshot({ path: '01-element-web-opened.png' }); |
|
||||||
|
|
||||||
console.debug("Click [Create Account] button"); |
|
||||||
await page.waitForSelector('a.mx_ButtonCreateAccount'); |
|
||||||
await page.click('a.mx_ButtonCreateAccount'); |
|
||||||
|
|
||||||
await page.screenshot({ path: '02-clicked-create-account-button.png' }); |
|
||||||
|
|
||||||
// The webapp should have loaded right now, if anything takes more than 5 seconds, something probably broke
|
|
||||||
page.setDefaultTimeout(5000); |
|
||||||
|
|
||||||
console.debug("Click [Edit] to switch homeserver"); |
|
||||||
await page.waitForSelector('div.mx_ServerPicker_change'); |
|
||||||
await page.click('div.mx_ServerPicker_change'); |
|
||||||
|
|
||||||
await page.screenshot({ path: '03-clicked-edit-homeserver-button.png' }); |
|
||||||
|
|
||||||
console.debug("Type in local homeserver url"); |
|
||||||
await page.waitForSelector('input#mx_homeserverInput'); |
|
||||||
await page.click('input#mx_homeserverInput'); |
|
||||||
await page.click('input#mx_homeserverInput'); |
|
||||||
await page.keyboard.type(homeserverUrl); |
|
||||||
|
|
||||||
await page.screenshot({ path: '04-typed-in-homeserver.png' }); |
|
||||||
|
|
||||||
console.debug("[Continue] with changed homeserver"); |
|
||||||
await page.waitForSelector("div.mx_ServerPickerDialog_continue"); |
|
||||||
await page.click('div.mx_ServerPickerDialog_continue'); |
|
||||||
|
|
||||||
await page.screenshot({ path: '05-back-to-enter-user-credentials.png' }); |
|
||||||
|
|
||||||
console.debug("Type in username"); |
|
||||||
await page.waitForSelector("input#mx_RegistrationForm_username"); |
|
||||||
await page.click('input#mx_RegistrationForm_username'); |
|
||||||
await page.keyboard.type(username); |
|
||||||
|
|
||||||
await page.screenshot({ path: '06-typed-in-username.png' }); |
|
||||||
|
|
||||||
console.debug("Type in password"); |
|
||||||
await page.waitForSelector("input#mx_RegistrationForm_password"); |
|
||||||
await page.click('input#mx_RegistrationForm_password'); |
|
||||||
await page.keyboard.type(password); |
|
||||||
|
|
||||||
await page.screenshot({ path: '07-typed-in-password-once.png' }); |
|
||||||
|
|
||||||
console.debug("Type in password again"); |
|
||||||
await page.waitForSelector("input#mx_RegistrationForm_passwordConfirm"); |
|
||||||
await page.click('input#mx_RegistrationForm_passwordConfirm'); |
|
||||||
await page.keyboard.type(password); |
|
||||||
|
|
||||||
await page.screenshot({ path: '08-typed-in-password-twice.png' }); |
|
||||||
|
|
||||||
console.debug("Click on [Register] to finish the account creation"); |
|
||||||
await page.waitForSelector("input.mx_Login_submit"); |
|
||||||
await page.click('input.mx_Login_submit'); |
|
||||||
|
|
||||||
await page.screenshot({ path: '09-clicked-on-register-button.png' }); |
|
||||||
|
|
||||||
// Waiting for the app to login can take some time, so be patient.
|
|
||||||
page.setDefaultTimeout(10000); |
|
||||||
|
|
||||||
console.debug("Wait for chat window to show up"); |
|
||||||
await page.waitForSelector("div.mx_HomePage_default_buttons"); |
|
||||||
console.debug("Apparently the registration worked."); |
|
||||||
|
|
||||||
await page.screenshot({ path: '10-logged-in-homescreen.png' }); |
|
||||||
|
|
||||||
|
|
||||||
// Close the browser and exit the script
|
|
||||||
await browser.close(); |
|
||||||
} |
|
||||||
Loading…
Reference in new issue