fix: use device_id when registering

TIL body.device_id != (*body).device_id, which is pretty bad, so I
renamed body.device_id to body.sender_device
This commit is contained in:
Timo Kösters 2020-10-18 20:33:12 +02:00
parent fccd3fdb88
commit f0a21b6165
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
23 changed files with 325 additions and 307 deletions

View file

@ -14,9 +14,9 @@ pub fn get_context_route(
db: State<'_, Database>,
body: Ruma<get_context::Request<'_>>,
) -> ConduitResult<get_context::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if !db.rooms.is_joined(sender_id, &body.room_id)? {
if !db.rooms.is_joined(sender_user, &body.room_id)? {
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"You don't have permission to view this room.",
@ -39,7 +39,7 @@ pub fn get_context_route(
let events_before = db
.rooms
.pdus_until(&sender_id, &body.room_id, base_token)
.pdus_until(&sender_user, &body.room_id, base_token)
.take(
u32::try_from(body.limit).map_err(|_| {
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")
@ -61,7 +61,7 @@ pub fn get_context_route(
let events_after = db
.rooms
.pdus_after(&sender_id, &body.room_id, base_token)
.pdus_after(&sender_user, &body.room_id, base_token)
.take(
u32::try_from(body.limit).map_err(|_| {
Error::BadRequest(ErrorKind::InvalidParam, "Limit value is invalid.")