mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
jsonrpc: add chat_get_neighboring_media function (#3610)
* jsonrpc: add `chat_get_neighboring_media` function * add number to changelog
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
### API-Changes
|
### API-Changes
|
||||||
- jsonrpc: add `mailingListAddress` property to `FullChat` #3607
|
- jsonrpc: add `mailingListAddress` property to `FullChat` #3607
|
||||||
- jsonrpc: add `MessageNotificationInfo` & `messageGetNotificationInfo()` #3614
|
- jsonrpc: add `MessageNotificationInfo` & `messageGetNotificationInfo()` #3614
|
||||||
|
- jsonrpc: add `chat_get_neighboring_media` function #3610
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
- truncate incoming messages by lines instead of just length #3480
|
- truncate incoming messages by lines instead of just length #3480
|
||||||
|
|||||||
@@ -850,6 +850,51 @@ impl CommandApi {
|
|||||||
Ok(media.iter().map(|msg_id| msg_id.to_u32()).collect())
|
Ok(media.iter().map(|msg_id| msg_id.to_u32()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Search next/previous message based on a given message and a list of types.
|
||||||
|
/// Typically used to implement the "next" and "previous" buttons
|
||||||
|
/// in a gallery or in a media player.
|
||||||
|
///
|
||||||
|
/// one combined call for getting chat::get_next_media for both directions
|
||||||
|
/// the manual chat::get_next_media in only one direction is not exposed by the jsonrpc yet
|
||||||
|
async fn chat_get_neighboring_media(
|
||||||
|
&self,
|
||||||
|
account_id: u32,
|
||||||
|
msg_id: u32,
|
||||||
|
message_type: MessageViewtype,
|
||||||
|
or_message_type2: Option<MessageViewtype>,
|
||||||
|
or_message_type3: Option<MessageViewtype>,
|
||||||
|
) -> Result<(Option<u32>, Option<u32>)> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
|
|
||||||
|
let msg_type: Viewtype = message_type.into();
|
||||||
|
let msg_type2: Viewtype = or_message_type2.map(|v| v.into()).unwrap_or_default();
|
||||||
|
let msg_type3: Viewtype = or_message_type3.map(|v| v.into()).unwrap_or_default();
|
||||||
|
|
||||||
|
let prev = chat::get_next_media(
|
||||||
|
&ctx,
|
||||||
|
MsgId::new(msg_id),
|
||||||
|
chat::Direction::Backward,
|
||||||
|
msg_type,
|
||||||
|
msg_type2,
|
||||||
|
msg_type3,
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
.map(|id| id.to_u32());
|
||||||
|
|
||||||
|
let next = chat::get_next_media(
|
||||||
|
&ctx,
|
||||||
|
MsgId::new(msg_id),
|
||||||
|
chat::Direction::Forward,
|
||||||
|
msg_type,
|
||||||
|
msg_type2,
|
||||||
|
msg_type3,
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
.map(|id| id.to_u32());
|
||||||
|
|
||||||
|
Ok((prev, next))
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
// connectivity
|
// connectivity
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|||||||
@@ -403,8 +403,8 @@ export class RawClient {
|
|||||||
/**
|
/**
|
||||||
* Fetch info desktop needs for creating a notification for a message
|
* Fetch info desktop needs for creating a notification for a message
|
||||||
*/
|
*/
|
||||||
public messageGetNotificationInfo(accountId: T.U32, messageId: T.U32): Promise<T.MessageNotificationData> {
|
public messageGetNotificationInfo(accountId: T.U32, messageId: T.U32): Promise<T.MessageNotificationInfo> {
|
||||||
return (this._transport.request('message_get_notification_info', [accountId, messageId] as RPC.Params)) as Promise<T.MessageNotificationData>;
|
return (this._transport.request('message_get_notification_info', [accountId, messageId] as RPC.Params)) as Promise<T.MessageNotificationInfo>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -506,6 +506,18 @@ export class RawClient {
|
|||||||
return (this._transport.request('chat_get_media', [accountId, chatId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<(T.U32)[]>;
|
return (this._transport.request('chat_get_media', [accountId, chatId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<(T.U32)[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search next/previous message based on a given message and a list of types.
|
||||||
|
* Typically used to implement the "next" and "previous" buttons
|
||||||
|
* in a gallery or in a media player.
|
||||||
|
*
|
||||||
|
* one combined call for getting chat::get_next_media for both directions
|
||||||
|
* the manual chat::get_next_media in only one direction is not exposed by the jsonrpc yet
|
||||||
|
*/
|
||||||
|
public chatGetNeighboringMedia(accountId: T.U32, msgId: T.U32, messageType: T.Viewtype, orMessageType2: (T.Viewtype|null), orMessageType3: (T.Viewtype|null)): Promise<[(T.U32|null),(T.U32|null)]> {
|
||||||
|
return (this._transport.request('chat_get_neighboring_media', [accountId, msgId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<[(T.U32|null),(T.U32|null)]>;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate that the network likely has come back.
|
* Indicate that the network likely has come back.
|
||||||
* or just that the network conditions might have changed
|
* or just that the network conditions might have changed
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ export type WebxdcMessageInfo={
|
|||||||
"internetAccess":boolean;};
|
"internetAccess":boolean;};
|
||||||
export type DownloadState=("Done"|"Available"|"Failure"|"InProgress");
|
export type DownloadState=("Done"|"Available"|"Failure"|"InProgress");
|
||||||
export type Message={"id":U32;"chatId":U32;"fromId":U32;"quote":(MessageQuote|null);"parentId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"webxdcInfo":(WebxdcMessageInfo|null);"downloadState":DownloadState;};
|
export type Message={"id":U32;"chatId":U32;"fromId":U32;"quote":(MessageQuote|null);"parentId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"webxdcInfo":(WebxdcMessageInfo|null);"downloadState":DownloadState;};
|
||||||
export type MessageNotificationData={"id":U32;"chatId":U32;"accountId":U32;"image":(string|null);"imageMimeType":(string|null);"chatName":string;"chatProfileImage":(string|null);
|
export type MessageNotificationInfo={"id":U32;"chatId":U32;"accountId":U32;"image":(string|null);"imageMimeType":(string|null);"chatName":string;"chatProfileImage":(string|null);
|
||||||
/**
|
/**
|
||||||
* also known as summary_text1
|
* also known as summary_text1
|
||||||
*/
|
*/
|
||||||
@@ -147,4 +147,4 @@ export type MessageNotificationData={"id":U32;"chatId":U32;"accountId":U32;"imag
|
|||||||
*/
|
*/
|
||||||
"summaryText":string;};
|
"summaryText":string;};
|
||||||
export type F64=number;
|
export type F64=number;
|
||||||
export type __AllTyps=[string,boolean,Record<string,string>,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record<string,string>,U32,string,(string|null),null,U32,Record<string,(string|null)>,null,U32,string,null,U32,string,Qr,U32,string,(string|null),U32,(string)[],Record<string,(string|null)>,U32,null,U32,null,U32,(U32)[],U32,U32,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record<U32,ChatListItemFetchResult>,U32,U32,FullChat,U32,U32,BasicChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,string,string,U32,U32,U32,null,U32,U32,(U32|null),U32,U32,MuteDuration,null,U32,U32,boolean,U32,(U32)[],null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record<U32,Message>,U32,U32,MessageNotificationData,U32,(U32)[],null,U32,U32,string,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record<U32,Contact>,U32,U32,string,U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],null,U32,U32,U32,string,U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,(U32)[],U32,null,U32,U32,null,U32,U32,(Message|null),U32,string,U32,U32,U32,U32,(string|null),(string|null),([F64,F64]|null),(U32|null),[U32,Message],U32,U32,(string|null),(string|null),(U32|null),null];
|
export type __AllTyps=[string,boolean,Record<string,string>,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record<string,string>,U32,string,(string|null),null,U32,Record<string,(string|null)>,null,U32,string,null,U32,string,Qr,U32,string,(string|null),U32,(string)[],Record<string,(string|null)>,U32,null,U32,null,U32,(U32)[],U32,U32,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record<U32,ChatListItemFetchResult>,U32,U32,FullChat,U32,U32,BasicChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,string,string,U32,U32,U32,null,U32,U32,(U32|null),U32,U32,MuteDuration,null,U32,U32,boolean,U32,(U32)[],null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record<U32,Message>,U32,U32,MessageNotificationInfo,U32,(U32)[],null,U32,U32,string,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record<U32,Contact>,U32,U32,string,U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,Viewtype,(Viewtype|null),(Viewtype|null),[(U32|null),(U32|null)],null,U32,U32,U32,string,U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,(U32)[],U32,null,U32,U32,null,U32,U32,(Message|null),U32,string,U32,U32,U32,U32,(string|null),(string|null),([F64,F64]|null),(U32|null),[U32,Message],U32,U32,(string|null),(string|null),(U32|null),null];
|
||||||
|
|||||||
Reference in New Issue
Block a user