Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions App/Services/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ final class MessageService: NSObject, Service, NSOpenSavePanelDelegate {
"Participant handles (phone or email). Phone numbers should use E.164 format",
items: .string()
),
"chatId": .string(
description:
"Conversation @id, as reported in a message's isPartOf. Fetches only messages in that conversation"
),
"start": .string(
description:
"Start of the date range (inclusive). If timezone is omitted, local time is assumed. Date-only uses local midnight.",
Expand Down Expand Up @@ -151,6 +155,14 @@ final class MessageService: NSObject, Service, NSOpenSavePanelDelegate {
$0.stringValue
}) ?? []

var requestedChatID: Chat.ID?
if let value = arguments["chatId"], !value.isNull {
guard let string = value.stringValue else {
throw ArgumentError.invalid("chatId has the wrong type")
}
requestedChatID = Chat.ID(rawValue: string)
}

// Either bound may be given alone; the other stays open.
// chat.db stores dates as Int64 nanoseconds since 2001, so the open ends
// use dates that fit, rather than Date.distantPast and Date.distantFuture.
Expand Down Expand Up @@ -201,6 +213,9 @@ final class MessageService: NSObject, Service, NSOpenSavePanelDelegate {
if !handles.isEmpty {
predicates.append(.participantHandles(Set(handles)))
}
if let requestedChatID {
predicates.append(.chatID(requestedChatID))
}
if let dateRange {
predicates.append(.dateRange(dateRange))
}
Expand Down