Update search endpoint to r0.6.0
This commit is contained in:
parent
210e3fd4a9
commit
762a65ec5e
@ -25,6 +25,7 @@ Breaking changes:
|
|||||||
request.
|
request.
|
||||||
* Add `M_USER_DEACTIVATED` to `error::ErrorKind`
|
* Add `M_USER_DEACTIVATED` to `error::ErrorKind`
|
||||||
* Make `display_name` field of `r0::membership::joined_events::RoomMember` optional
|
* Make `display_name` field of `r0::membership::joined_events::RoomMember` optional
|
||||||
|
* Update `r0::search::search_events` to r0.6.0
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
@ -4,7 +4,10 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_events::{collections::all::Event, EventJson};
|
use ruma_events::{
|
||||||
|
collections::all::{Event, StateEvent},
|
||||||
|
EventJson,
|
||||||
|
};
|
||||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -53,8 +56,6 @@ pub struct Criteria {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub event_context: Option<EventContext>,
|
pub event_context: Option<EventContext>,
|
||||||
/// A `Filter` to apply to the search.
|
/// A `Filter` to apply to the search.
|
||||||
// TODO: "timeline" key might need to be included.
|
|
||||||
// See https://github.com/matrix-org/matrix-doc/issues/598.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub filter: Option<RoomEventFilter>,
|
pub filter: Option<RoomEventFilter>,
|
||||||
/// Requests that the server partitions the result set based on the provided list of keys.
|
/// Requests that the server partitions the result set based on the provided list of keys.
|
||||||
@ -77,9 +78,11 @@ pub struct Criteria {
|
|||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
pub struct EventContext {
|
pub struct EventContext {
|
||||||
/// How many events after the result are returned.
|
/// How many events after the result are returned.
|
||||||
pub after_limit: UInt,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub after_limit: Option<UInt>,
|
||||||
/// How many events before the result are returned.
|
/// How many events before the result are returned.
|
||||||
pub before_limit: UInt,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub before_limit: Option<UInt>,
|
||||||
/// Requests that the server returns the historic profile information for the users that
|
/// Requests that the server returns the historic profile information for the users that
|
||||||
/// sent the events that were returned.
|
/// sent the events that were returned.
|
||||||
pub include_profile: bool,
|
pub include_profile: bool,
|
||||||
@ -89,26 +92,27 @@ pub struct EventContext {
|
|||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct EventContextResult {
|
pub struct EventContextResult {
|
||||||
/// Pagination token for the end of the chunk.
|
/// Pagination token for the end of the chunk.
|
||||||
pub end: String,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub end: Option<String>,
|
||||||
/// Events just after the result.
|
/// Events just after the result.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub events_after: Option<Vec<EventJson<Event>>>,
|
pub events_after: Vec<EventJson<Event>>,
|
||||||
/// Events just before the result.
|
/// Events just before the result.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub events_before: Option<Vec<EventJson<Event>>>,
|
pub events_before: Vec<EventJson<Event>>,
|
||||||
/// The historic profile information of the users that sent the events returned.
|
/// The historic profile information of the users that sent the events returned.
|
||||||
// TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub profile_info: Option<BTreeMap<UserId, UserProfile>>,
|
pub profile_info: Option<BTreeMap<UserId, UserProfile>>,
|
||||||
/// Pagination token for the start of the chunk.
|
/// Pagination token for the start of the chunk.
|
||||||
pub start: String,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub start: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A grouping for partioning the result set.
|
/// A grouping for partioning the result set.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
pub struct Grouping {
|
pub struct Grouping {
|
||||||
/// The key within events to use for this grouping.
|
/// The key within events to use for this grouping.
|
||||||
pub key: GroupingKey,
|
pub key: Option<GroupingKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The key within events to use for this grouping.
|
/// The key within events to use for this grouping.
|
||||||
@ -125,6 +129,7 @@ pub enum GroupingKey {
|
|||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Groupings {
|
pub struct Groupings {
|
||||||
/// List of groups to request.
|
/// List of groups to request.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub group_by: Vec<Grouping>,
|
pub group_by: Vec<Grouping>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +172,7 @@ pub struct RoomEventJsons {
|
|||||||
/// An approximate count of the total number of results found.
|
/// An approximate count of the total number of results found.
|
||||||
pub count: UInt,
|
pub count: UInt,
|
||||||
/// Any groups that were requested.
|
/// Any groups that were requested.
|
||||||
// TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
|
pub groups: BTreeMap<GroupingKey, BTreeMap<RoomIdOrUserId, ResultGroup>>,
|
||||||
pub groups: BTreeMap<GroupingKey, BTreeMap<RoomId, ResultGroup>>,
|
|
||||||
/// Token that can be used to get the next batch of results, by passing as the `next_batch`
|
/// Token that can be used to get the next batch of results, by passing as the `next_batch`
|
||||||
/// parameter to the next call. If this field is absent, there are no more results.
|
/// parameter to the next call. If this field is absent, there are no more results.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -177,9 +181,12 @@ pub struct RoomEventJsons {
|
|||||||
pub results: Vec<SearchResult>,
|
pub results: Vec<SearchResult>,
|
||||||
/// The current state for every room in the results. This is included if the request had the
|
/// The current state for every room in the results. This is included if the request had the
|
||||||
/// `include_state` key set with a value of `true`.
|
/// `include_state` key set with a value of `true`.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
// TODO: Major WTF here. https://github.com/matrix-org/matrix-doc/issues/773
|
pub state: BTreeMap<RoomId, Vec<EventJson<StateEvent>>>,
|
||||||
pub state: Option<()>,
|
/// List of words which should be highlighted, useful for stemming which may
|
||||||
|
/// change the query terms.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub highlights: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A grouping of results, if requested.
|
/// A grouping of results, if requested.
|
||||||
@ -203,9 +210,11 @@ pub struct SearchResult {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub context: Option<EventContextResult>,
|
pub context: Option<EventContextResult>,
|
||||||
/// A number that describes how closely this result matches the search. Higher is closer.
|
/// A number that describes how closely this result matches the search. Higher is closer.
|
||||||
pub rank: f64,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub rank: Option<UInt>,
|
||||||
/// The event that matched.
|
/// The event that matched.
|
||||||
pub result: EventJson<Event>,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub result: Option<EventJson<Event>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A user profile.
|
/// A user profile.
|
||||||
@ -218,3 +227,12 @@ pub struct UserProfile {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents either a room or user ID for returning grouped search results.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
|
pub enum RoomIdOrUserId {
|
||||||
|
/// Represents a room ID.
|
||||||
|
RoomId(RoomId),
|
||||||
|
/// Represents a user ID.
|
||||||
|
UserId(UserId),
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user