Fix search types

This commit is contained in:
tezlm 2023-12-04 00:03:26 -08:00
parent c377f8ec91
commit 633cb67877
Signed by: tezlm
GPG key ID: 649733FCD94AFBBA
4 changed files with 36 additions and 6 deletions

View file

@ -40,6 +40,12 @@ pub mod v3 {
#[ruma_api(query)]
pub next_batch: Option<String>,
/// The maximum number of results to return.
///
/// Defaults to 10.
#[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
pub limit: UInt,
/// Describes what to search for
pub query: String,
@ -84,6 +90,7 @@ pub mod v3 {
query,
context: EventContext::new(),
order: Order::Newest,
limit: uint!(10),
}
}
}
@ -262,4 +269,12 @@ pub mod v3 {
self.avatar_url.is_none() && self.displayname.is_none()
}
}
fn default_limit() -> UInt {
uint!(10)
}
fn is_default_limit(limit: &UInt) -> bool {
limit == &default_limit()
}
}

View file

@ -7,7 +7,7 @@ pub mod v3 {
//!
//! [spec]: TODO: write
use js_int::UInt;
use js_int::{UInt, uint};
use ruma_common::{
api::{request, response, Metadata},
metadata,
@ -35,6 +35,12 @@ pub mod v3 {
/// If given, this should be a `next_batch` result from a previous call to this endpoint.
#[ruma_api(query)]
pub next_batch: Option<String>,
/// The maximum number of results to return.
///
/// Defaults to 10.
#[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
pub limit: UInt,
/// Describes what to search for
pub query: String,
@ -75,6 +81,7 @@ pub mod v3 {
next_batch: None,
query,
order: Order::default(),
limit: uint!(10),
}
}
}
@ -119,4 +126,12 @@ pub mod v3 {
/// The event that matched.
pub event: Raw<AnyTimelineEvent>,
}
fn default_limit() -> UInt {
uint!(10)
}
fn is_default_limit(limit: &UInt) -> bool {
limit == &default_limit()
}
}

View file

@ -10,7 +10,7 @@ pub mod v3 {
use js_int::{uint, UInt};
use ruma_common::{
api::{request, response, Metadata},
metadata,
metadata, OwnedUserId,
};
use serde::{Deserialize, Serialize};
use ruma_common::OwnedMxcUri;
@ -62,8 +62,11 @@ pub mod v3 {
}
/// A user which really should be moved into its own api chunk
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct User {
/// The user's matrix id
pub user_id: OwnedUserId,
/// The user's avatar URL, if set.
///
/// If you activate the `compat-empty-string-null` feature, this field being an empty

View file

@ -70,9 +70,6 @@ event_enum! {
"m.room.topic" => super::room::topic,
"m.space.child" => super::space::child,
"m.space.parent" => super::space::parent,
#[cfg(feature = "unstable-msc3401")]
#[ruma_enum(alias = "m.call.member")]
"org.matrix.msc3401.call.member" => super::call::member,
}
/// Any to-device event.