mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 01:27:27 +00:00
fixes EP review
This commit is contained in:
1 parent
0a245c67cb
commit
a8235b9440
36 files changed
+292
-21459
No files matched your search
@@ -1496,29 +1496,28 @@ enum NameRegistration: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
// stock derivation cannot decode this: the core encodes it with a flat "type" tag, not swift's nested shape
|
||||
extension NameRegistration: Decodable {
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type, expires, graceUntil, reservedReason_, pricing, reservedReason
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try c.decode(String.self, forKey: CodingKeys.type)
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decode(String.self, forKey: .type)
|
||||
switch type {
|
||||
case "registered":
|
||||
let expires = try c.decodeIfPresent(Int64.self, forKey: CodingKeys.expires)
|
||||
let graceUntil = try c.decodeIfPresent(Int64.self, forKey: CodingKeys.graceUntil)
|
||||
let reservedReason_ = try c.decodeIfPresent(String.self, forKey: CodingKeys.reservedReason_)
|
||||
let expires = try container.decodeIfPresent(Int64.self, forKey: .expires)
|
||||
let graceUntil = try container.decodeIfPresent(Int64.self, forKey: .graceUntil)
|
||||
let reservedReason_ = try container.decodeIfPresent(String.self, forKey: .reservedReason_)
|
||||
self = .registered(expires: expires, graceUntil: graceUntil, reservedReason_: reservedReason_)
|
||||
case "available":
|
||||
let pricing = try c.decode(NamePricing.self, forKey: CodingKeys.pricing)
|
||||
let pricing = try container.decode(NamePricing.self, forKey: .pricing)
|
||||
self = .available(pricing: pricing)
|
||||
case "reserved":
|
||||
let reservedReason = try c.decode(String.self, forKey: CodingKeys.reservedReason)
|
||||
let reservedReason = try container.decode(String.self, forKey: .reservedReason)
|
||||
self = .reserved(reservedReason: reservedReason)
|
||||
default:
|
||||
throw DecodingError.dataCorruptedError(forKey: CodingKeys.type, in: c, debugDescription: "Unsupported name registration type: \(type)")
|
||||
throw DecodingError.dataCorruptedError(forKey: .type, in: container, debugDescription: "Unknown NameRegistration type: \(type)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1499,8 +1499,3 @@ enum UIRemoteCtrlSessionState {
|
||||
case pendingConfirmation(remoteCtrl_: RemoteCtrlInfo?, sessionCode: String)
|
||||
case connected(remoteCtrl: RemoteCtrlInfo, sessionCode: String)
|
||||
}
|
||||
|
||||
struct SimplexNameResolved: Codable {
|
||||
var at: Int64
|
||||
var expires: Int64?
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ func apiConnectPlan(connLink: String, resolveMode: PlanResolveMode = .unknown, l
|
||||
}
|
||||
// a .never (typing) search that matches nothing locally is not an error to surface
|
||||
if case .error(.error(.notResolvedLocally)) = r { return nil }
|
||||
if let r, inProgress.boxedValue { await apiConnectResponseAlert(r) }
|
||||
if let r { await apiConnectResponseAlert(r) }
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,34 +1321,6 @@ private func showOpenKnownGroupAlert(
|
||||
|
||||
private let simplexNamesHowToURL = "https://simplex.domains/#testing"
|
||||
|
||||
private let nameResolvedDaySeconds: Int64 = 24 * 60 * 60
|
||||
|
||||
private func nowSeconds() -> Int64 { Int64(Date.now.timeIntervalSince1970) }
|
||||
|
||||
private func saveNamesResolvedAt(_ m: [String: SimplexNameResolved]) {
|
||||
let now = nowSeconds()
|
||||
simplexNamesResolvedAtDefault.set(m.filter { now - $0.value.at < 7 * nameResolvedDaySeconds })
|
||||
}
|
||||
|
||||
func simplexNameResolvedRecently(_ domain: SimplexDomain) -> Bool {
|
||||
guard let r = simplexNamesResolvedAtDefault.get()[domain.fullDomainName] else { return false }
|
||||
let now = nowSeconds()
|
||||
if now - r.at >= nameResolvedDaySeconds { return false }
|
||||
return r.expires.map { now < $0 } ?? true
|
||||
}
|
||||
|
||||
func recordSimplexNameResolved(_ domain: SimplexDomain, _ reg: NameRegistration?) {
|
||||
var m = simplexNamesResolvedAtDefault.get()
|
||||
let expires: Int64? = if case let .registered(expires, _, _) = reg { expires } else { nil }
|
||||
m[domain.fullDomainName] = SimplexNameResolved(at: nowSeconds(), expires: expires)
|
||||
saveNamesResolvedAt(m)
|
||||
}
|
||||
|
||||
func clearSimplexNameResolved(_ fullDomainName: String) {
|
||||
var m = simplexNamesResolvedAtDefault.get()
|
||||
if m.removeValue(forKey: fullDomainName) != nil { saveNamesResolvedAt(m) }
|
||||
}
|
||||
|
||||
private func nameDate(_ seconds: Int64) -> String {
|
||||
Date(timeIntervalSince1970: TimeInterval(seconds)).formatted(date: .abbreviated, time: .omitted)
|
||||
}
|
||||
@@ -1477,17 +1449,7 @@ func planAndConnect(
|
||||
|
||||
func connectTask(_ inProgress: BoxedValue<Bool>) {
|
||||
Task {
|
||||
let nameTarget: SimplexNameInfo? = if case let .name(_, nameInfo) = strConnectTarget(shortOrFullLink) { nameInfo } else { nil }
|
||||
var result: ConnectionPlanResult? = nil
|
||||
if let nameTarget, simplexNameResolvedRecently(nameTarget.nameDomain) {
|
||||
result = await apiConnectPlan(connLink: shortOrFullLink, resolveMode: .never, linkOwnerSig: linkOwnerSig, inProgress: BoxedValue(false))
|
||||
}
|
||||
if result == nil && inProgress.boxedValue {
|
||||
result = await apiConnectPlan(connLink: shortOrFullLink, resolveMode: nameTarget != nil ? .all : .unknown, linkOwnerSig: linkOwnerSig, inProgress: inProgress)
|
||||
if let nameTarget, let result {
|
||||
recordSimplexNameResolved(nameTarget.nameDomain, result.connectionPlan.nameRegistration)
|
||||
}
|
||||
}
|
||||
let result = await apiConnectPlan(connLink: shortOrFullLink, linkOwnerSig: linkOwnerSig, inProgress: inProgress)
|
||||
await MainActor.run {
|
||||
ConnectProgressManager.shared.stopConnectProgress()
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ let DEFAULT_PRIVACY_LINK_PREVIEWS = "privacyLinkPreviews" // deprecated, moved t
|
||||
let DEFAULT_PRIVACY_SIMPLEX_LINK_MODE = "privacySimplexLinkMode"
|
||||
let DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS = "privacyShowChatPreviews"
|
||||
let DEFAULT_PRIVACY_VERIFY_SIMPLEX_NAMES = "privacyVerifySimplexNames"
|
||||
let DEFAULT_SIMPLEX_NAMES_RESOLVED_AT = "simplexNamesResolvedAt"
|
||||
let DEFAULT_PRIVACY_SHOW_SIGNATURE = "privacyShowSignature"
|
||||
let DEFAULT_PRIVACY_SHOW_FILE_ENCRYPTION = "privacyShowEncryption"
|
||||
let DEFAULT_PRIVACY_SAVE_LAST_DRAFT = "privacySaveLastDraft"
|
||||
@@ -291,8 +290,6 @@ public class CodableDefault<T: Codable> {
|
||||
|
||||
let networkProxyDefault: CodableDefault<NetworkProxy> = CodableDefault(defaults: UserDefaults.standard, forKey: DEFAULT_NETWORK_PROXY, withDefault: NetworkProxy.def)
|
||||
|
||||
let simplexNamesResolvedAtDefault = CodableDefault<[String: SimplexNameResolved]>(defaults: UserDefaults.standard, forKey: DEFAULT_SIMPLEX_NAMES_RESOLVED_AT, withDefault: [:])
|
||||
|
||||
struct SettingsView: View {
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@@ -205,7 +205,6 @@ struct UserAddressView: View {
|
||||
save: { simplexDomain in
|
||||
do {
|
||||
let u = try await apiSetUserDomain(simplexDomain)
|
||||
if let d = chatModel.currentUser?.profile.contactDomain?.domain { clearSimplexNameResolved(d) }
|
||||
await MainActor.run { chatModel.updateUser(u) }
|
||||
return true
|
||||
} catch {
|
||||
|
||||
@@ -5252,9 +5252,6 @@ enum class SimplexTLD {
|
||||
@SerialName("web") web
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SimplexNameResolved(val at: Long, val expires: Long? = null)
|
||||
|
||||
@Serializable
|
||||
sealed class NameRegistration {
|
||||
// held by someone; expires/graceUntil are absent from an older router, which means "not known", not "live forever"
|
||||
|
||||
-2
@@ -123,7 +123,6 @@ class AppPreferences {
|
||||
val privacyAcceptImages = mkBoolPreference(SHARED_PREFS_PRIVACY_ACCEPT_IMAGES, true)
|
||||
val privacyLinkPreviews = mkBoolPreference(SHARED_PREFS_PRIVACY_LINK_PREVIEWS, true)
|
||||
val privacyVerifySimplexNames = mkBoolPreference(SHARED_PREFS_PRIVACY_VERIFY_SIMPLEX_NAMES, false)
|
||||
val simplexNamesResolvedAt = mkStrPreference(SHARED_PREFS_SIMPLEX_NAMES_RESOLVED_AT, null)
|
||||
val privacyLinkPreviewsShowAlert = mkBoolPreference(SHARED_PREFS_PRIVACY_LINK_PREVIEWS_SHOW_ALERT, true)
|
||||
val privacySanitizeLinks = mkBoolPreference(SHARED_PREFS_PRIVACY_SANITIZE_LINKS, false)
|
||||
// TODO remove
|
||||
@@ -412,7 +411,6 @@ class AppPreferences {
|
||||
private const val SHARED_PREFS_PRIVACY_TRANSFER_IMAGES_INLINE = "PrivacyTransferImagesInline"
|
||||
private const val SHARED_PREFS_PRIVACY_LINK_PREVIEWS = "PrivacyLinkPreviews"
|
||||
private const val SHARED_PREFS_PRIVACY_VERIFY_SIMPLEX_NAMES = "PrivacyVerifySimplexNames"
|
||||
private const val SHARED_PREFS_SIMPLEX_NAMES_RESOLVED_AT = "SimplexNamesResolvedAt"
|
||||
private const val SHARED_PREFS_PRIVACY_LINK_PREVIEWS_SHOW_ALERT = "PrivacyLinkPreviewsShowAlert"
|
||||
private const val SHARED_PREFS_PRIVACY_SANITIZE_LINKS = "PrivacySanitizeLinks"
|
||||
private const val SHARED_PREFS_PRIVACY_CHAT_LIST_OPEN_LINKS = "ChatListOpenLinks" // TODO remove
|
||||
|
||||
+1
-51
@@ -22,7 +22,6 @@ import chat.simplex.common.views.usersettings.simplexTeamUri
|
||||
import chat.simplex.res.MR
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.datetime.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
enum class ConnectionLinkType {
|
||||
INVITATION, CONTACT, GROUP
|
||||
@@ -73,46 +72,8 @@ private fun openNameHowTo(uriHandler: UriHandler) = openBrowserAlert(SIMPLEX_NAM
|
||||
|
||||
private const val SIMPLEX_NAMES_HOWTO_URL = "https://simplex.domains/#testing"
|
||||
|
||||
private const val NAME_RESOLVED_DAY_SECONDS = 24 * 60 * 60L
|
||||
|
||||
private fun nowSeconds(): Long = Clock.System.now().epochSeconds
|
||||
|
||||
private fun loadNamesResolvedAt(): MutableMap<String, SimplexNameResolved> =
|
||||
try {
|
||||
val s = ChatController.appPrefs.simplexNamesResolvedAt.get() ?: return mutableMapOf()
|
||||
json.decodeFromString<Map<String, SimplexNameResolved>>(s).toMutableMap()
|
||||
} catch (e: Exception) {
|
||||
mutableMapOf()
|
||||
}
|
||||
|
||||
private fun saveNamesResolvedAt(m: Map<String, SimplexNameResolved>) {
|
||||
val now = nowSeconds()
|
||||
val kept = m.filterValues { now - it.at < 7 * NAME_RESOLVED_DAY_SECONDS }
|
||||
try {
|
||||
ChatController.appPrefs.simplexNamesResolvedAt.set(json.encodeToString<Map<String, SimplexNameResolved>>(kept))
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "saveNamesResolvedAt: ${e.stackTraceToString()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun simplexNameResolvedRecently(domain: SimplexDomain): Boolean {
|
||||
val r = loadNamesResolvedAt()[domain.fullDomainName] ?: return false
|
||||
val now = nowSeconds()
|
||||
if (now - r.at >= NAME_RESOLVED_DAY_SECONDS) return false
|
||||
return r.expires == null || now < r.expires
|
||||
}
|
||||
|
||||
fun recordSimplexNameResolved(domain: SimplexDomain, reg: NameRegistration?) {
|
||||
val m = loadNamesResolvedAt()
|
||||
m[domain.fullDomainName] = SimplexNameResolved(nowSeconds(), (reg as? NameRegistration.Registered)?.expires)
|
||||
saveNamesResolvedAt(m)
|
||||
}
|
||||
|
||||
fun clearSimplexNameResolved(fullDomainName: String) {
|
||||
val m = loadNamesResolvedAt()
|
||||
if (m.remove(fullDomainName) != null) saveNamesResolvedAt(m)
|
||||
}
|
||||
|
||||
private fun showNameRegistrationAlert(
|
||||
rhId: Long?,
|
||||
domain: SimplexDomain,
|
||||
@@ -230,18 +191,7 @@ private suspend fun planAndConnectTask(
|
||||
cleanup?.invoke()
|
||||
completable.complete(!completable.isActive)
|
||||
}
|
||||
val nameTarget = (strConnectTarget(shortOrFullLink.trim()) as? ConnectTarget.Name)?.nameInfo
|
||||
val freshName = nameTarget != null && simplexNameResolvedRecently(nameTarget.nameDomain)
|
||||
var result = if (freshName) {
|
||||
chatModel.controller.apiConnectPlan(rhId, shortOrFullLink, PlanResolveMode.PRMNever, linkOwnerSig, mutableStateOf(false))
|
||||
} else null
|
||||
if (result == null && inProgress.value) {
|
||||
val mode = if (nameTarget != null) PlanResolveMode.PRMAll else PlanResolveMode.PRMUnknown
|
||||
result = chatModel.controller.apiConnectPlan(rhId, shortOrFullLink, mode, linkOwnerSig, inProgress)
|
||||
if (nameTarget != null && result != null) {
|
||||
recordSimplexNameResolved(nameTarget.nameDomain, result.connectionPlan.nameRegistration())
|
||||
}
|
||||
}
|
||||
val result = chatModel.controller.apiConnectPlan(rhId, shortOrFullLink, linkOwnerSig = linkOwnerSig, inProgress = inProgress)
|
||||
connectProgressManager.stopConnectProgress()
|
||||
if (!inProgress.value) { return completable }
|
||||
if (result != null) {
|
||||
|
||||
-1
@@ -388,7 +388,6 @@ private fun UserAddressLayout(
|
||||
save = { simplexDomain ->
|
||||
try {
|
||||
val u = chatModel.controller.apiSetUserDomain(user?.remoteHostId, simplexDomain)
|
||||
domain?.let { clearSimplexNameResolved(it) }
|
||||
withContext(Dispatchers.Main) { chatModel.updateUser(u) }
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,868 +0,0 @@
|
||||
# API Events
|
||||
|
||||
This file is generated automatically.
|
||||
|
||||
[Contact connection events](#contact-connection-events)
|
||||
- Main event
|
||||
- [ContactConnected](#contactconnected)
|
||||
- Other events
|
||||
- [ContactUpdated](#contactupdated)
|
||||
- [ContactDeletedByContact](#contactdeletedbycontact)
|
||||
- [ReceivedContactRequest](#receivedcontactrequest)
|
||||
- [NewMemberContactReceivedInv](#newmembercontactreceivedinv)
|
||||
- [ContactSndReady](#contactsndready)
|
||||
|
||||
[Message events](#message-events)
|
||||
- Main event
|
||||
- [NewChatItems](#newchatitems)
|
||||
- Other events
|
||||
- [ChatItemReaction](#chatitemreaction)
|
||||
- [ChatItemsDeleted](#chatitemsdeleted)
|
||||
- [ChatItemUpdated](#chatitemupdated)
|
||||
- [GroupChatItemsDeleted](#groupchatitemsdeleted)
|
||||
- [ChatItemsStatusesUpdated](#chatitemsstatusesupdated)
|
||||
|
||||
[Group events](#group-events)
|
||||
- Main events
|
||||
- [ReceivedGroupInvitation](#receivedgroupinvitation)
|
||||
- [UserJoinedGroup](#userjoinedgroup)
|
||||
- [GroupUpdated](#groupupdated)
|
||||
- [JoinedGroupMember](#joinedgroupmember)
|
||||
- [MemberRole](#memberrole)
|
||||
- [DeletedMember](#deletedmember)
|
||||
- [LeftMember](#leftmember)
|
||||
- [DeletedMemberUser](#deletedmemberuser)
|
||||
- [GroupDeleted](#groupdeleted)
|
||||
- Other events
|
||||
- [ConnectedToGroupMember](#connectedtogroupmember)
|
||||
- [MemberAcceptedByOther](#memberacceptedbyother)
|
||||
- [MemberBlockedForAll](#memberblockedforall)
|
||||
- [GroupMemberUpdated](#groupmemberupdated)
|
||||
- [GroupLinkDataUpdated](#grouplinkdataupdated)
|
||||
- [GroupRelayUpdated](#grouprelayupdated)
|
||||
|
||||
[File events](#file-events)
|
||||
- Main events
|
||||
- [RcvFileDescrReady](#rcvfiledescrready)
|
||||
- [RcvFileComplete](#rcvfilecomplete)
|
||||
- [SndFileCompleteXFTP](#sndfilecompletexftp)
|
||||
- Other events
|
||||
- [RcvFileStart](#rcvfilestart)
|
||||
- [RcvFileSndCancelled](#rcvfilesndcancelled)
|
||||
- [RcvFileAccepted](#rcvfileaccepted)
|
||||
- [RcvFileError](#rcvfileerror)
|
||||
- [RcvFileWarning](#rcvfilewarning)
|
||||
- [SndFileError](#sndfileerror)
|
||||
- [SndFileWarning](#sndfilewarning)
|
||||
|
||||
[Connection progress events](#connection-progress-events)
|
||||
- [AcceptingContactRequest](#acceptingcontactrequest)
|
||||
- [AcceptingBusinessRequest](#acceptingbusinessrequest)
|
||||
- [ContactConnecting](#contactconnecting)
|
||||
- [BusinessLinkConnecting](#businesslinkconnecting)
|
||||
- [JoinedGroupMemberConnecting](#joinedgroupmemberconnecting)
|
||||
- [GroupLinkConnecting](#grouplinkconnecting)
|
||||
|
||||
[Network connection events](#network-connection-events)
|
||||
- [HostConnected](#hostconnected)
|
||||
- [HostDisconnected](#hostdisconnected)
|
||||
- [SubscriptionStatus](#subscriptionstatus)
|
||||
|
||||
[Service events](#service-events)
|
||||
- [ServiceRequest](#servicerequest)
|
||||
- [ServiceReplySent](#servicereplysent)
|
||||
|
||||
[Remote control events](#remote-control-events)
|
||||
- [RemoteCtrlSessionCode](#remotectrlsessioncode)
|
||||
- [RemoteCtrlStopped](#remotectrlstopped)
|
||||
|
||||
[Error events](#error-events)
|
||||
- [MessageError](#messageerror)
|
||||
- [ChatError](#chaterror)
|
||||
- [ChatErrors](#chaterrors)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Contact connection events
|
||||
|
||||
Bots must use these events to process connecting users.
|
||||
|
||||
Most bots enable auto-accept and don't need to accept connections via commands.
|
||||
|
||||
You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
|
||||
- [APIShowMyAddress](./COMMANDS.md#apishowmyaddress) to check if address exists,
|
||||
- [APICreateMyAddress](./COMMANDS.md#apicreatemyaddress) to create address,
|
||||
- [APISetAddressSettings](./COMMANDS.md#apisetaddresssettings) to enable auto-access.
|
||||
|
||||
|
||||
### ContactConnected
|
||||
|
||||
This event is sent after a user connects via bot SimpleX address (not a business address).
|
||||
|
||||
**Record type**:
|
||||
- type: "contactConnected"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
- userCustomProfile: [Profile](./TYPES.md#profile)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ContactUpdated
|
||||
|
||||
Contact profile of another user is updated.
|
||||
|
||||
**Record type**:
|
||||
- type: "contactUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- fromContact: [Contact](./TYPES.md#contact)
|
||||
- toContact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ContactDeletedByContact
|
||||
|
||||
Bot user's connection with another contact is deleted (conversation is kept).
|
||||
|
||||
**Record type**:
|
||||
- type: "contactDeletedByContact"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ReceivedContactRequest
|
||||
|
||||
Contact request received.
|
||||
|
||||
This event is only sent when auto-accept is disabled.
|
||||
|
||||
The request needs to be accepted using [APIAcceptContact](./COMMANDS.md#apiacceptcontact) command
|
||||
|
||||
**Record type**:
|
||||
- type: "receivedContactRequest"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contactRequest: [UserContactRequest](./TYPES.md#usercontactrequest)
|
||||
- chat_: [AChat](./TYPES.md#achat)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### NewMemberContactReceivedInv
|
||||
|
||||
Received invitation to connect directly with a group member.
|
||||
|
||||
This event only needs to be processed to associate contact with group, the connection will proceed automatically.
|
||||
|
||||
**Record type**:
|
||||
- type: "newMemberContactReceivedInv"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ContactSndReady
|
||||
|
||||
Connecting via 1-time invitation or after accepting contact request.
|
||||
|
||||
After this event bot can send messages to this contact.
|
||||
|
||||
**Record type**:
|
||||
- type: "contactSndReady"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Message events
|
||||
|
||||
Bots must use these events to process received messages.
|
||||
|
||||
|
||||
### NewChatItems
|
||||
|
||||
Received message(s).
|
||||
|
||||
**Record type**:
|
||||
- type: "newChatItems"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItems: [[AChatItem](./TYPES.md#achatitem)]
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatItemReaction
|
||||
|
||||
Received message reaction.
|
||||
|
||||
**Record type**:
|
||||
- type: "chatItemReaction"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- added: bool
|
||||
- reaction: [ACIReaction](./TYPES.md#acireaction)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatItemsDeleted
|
||||
|
||||
Message was deleted by another user.
|
||||
|
||||
**Record type**:
|
||||
- type: "chatItemsDeleted"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItemDeletions: [[ChatItemDeletion](./TYPES.md#chatitemdeletion)]
|
||||
- byUser: bool
|
||||
- timed: bool
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatItemUpdated
|
||||
|
||||
Message was updated by another user.
|
||||
|
||||
**Record type**:
|
||||
- type: "chatItemUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupChatItemsDeleted
|
||||
|
||||
Group messages are deleted or moderated.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupChatItemsDeleted"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- chatItemIDs: [int64]
|
||||
- byUser: bool
|
||||
- member_: [GroupMember](./TYPES.md#groupmember)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatItemsStatusesUpdated
|
||||
|
||||
Message delivery status updates.
|
||||
|
||||
**Record type**:
|
||||
- type: "chatItemsStatusesUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItems: [[AChatItem](./TYPES.md#achatitem)]
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Group events
|
||||
|
||||
Bots may use these events to manage users' groups and business address groups.
|
||||
|
||||
*Please note*: programming groups is more complex than programming direct connections
|
||||
|
||||
|
||||
### ReceivedGroupInvitation
|
||||
|
||||
Received group invitation.
|
||||
|
||||
**Record type**:
|
||||
- type: "receivedGroupInvitation"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
- fromMemberRole: [GroupMemberRole](./TYPES.md#groupmemberrole)
|
||||
- memberRole: [GroupMemberRole](./TYPES.md#groupmemberrole)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### UserJoinedGroup
|
||||
|
||||
Bot user joined group. Received when connection via group link completes.
|
||||
|
||||
**Record type**:
|
||||
- type: "userJoinedGroup"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- hostMember: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupUpdated
|
||||
|
||||
Group profile or preferences updated.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- fromGroup: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- toGroup: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member_: [GroupMember](./TYPES.md#groupmember)?
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### JoinedGroupMember
|
||||
|
||||
Another member joined group.
|
||||
|
||||
**Record type**:
|
||||
- type: "joinedGroupMember"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### MemberRole
|
||||
|
||||
Member (or bot user's) group role changed.
|
||||
|
||||
**Record type**:
|
||||
- type: "memberRole"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- byMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- fromRole: [GroupMemberRole](./TYPES.md#groupmemberrole)
|
||||
- toRole: [GroupMemberRole](./TYPES.md#groupmemberrole)
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### DeletedMember
|
||||
|
||||
Another member is removed from the group.
|
||||
|
||||
**Record type**:
|
||||
- type: "deletedMember"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- byMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- deletedMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- withMessages: bool
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### LeftMember
|
||||
|
||||
Another member left the group.
|
||||
|
||||
**Record type**:
|
||||
- type: "leftMember"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### DeletedMemberUser
|
||||
|
||||
Bot user was removed from the group.
|
||||
|
||||
**Record type**:
|
||||
- type: "deletedMemberUser"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- withMessages: bool
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupDeleted
|
||||
|
||||
Group was deleted by the owner (not bot user).
|
||||
|
||||
**Record type**:
|
||||
- type: "groupDeleted"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ConnectedToGroupMember
|
||||
|
||||
Connected to another group member.
|
||||
|
||||
**Record type**:
|
||||
- type: "connectedToGroupMember"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- memberContact: [Contact](./TYPES.md#contact)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### MemberAcceptedByOther
|
||||
|
||||
Another group owner, admin or moderator accepted member to the group after review ("knocking").
|
||||
|
||||
**Record type**:
|
||||
- type: "memberAcceptedByOther"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- acceptingMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### MemberBlockedForAll
|
||||
|
||||
Another member blocked for all members.
|
||||
|
||||
**Record type**:
|
||||
- type: "memberBlockedForAll"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- byMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- blocked: bool
|
||||
- msgSigned: [MsgSigStatus](./TYPES.md#msgsigstatus)?
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupMemberUpdated
|
||||
|
||||
Another group member profile updated.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupMemberUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- fromMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- toMember: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupLinkDataUpdated
|
||||
|
||||
Group link data updated.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupLinkDataUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- groupLink: [GroupLink](./TYPES.md#grouplink)
|
||||
- groupRelays: [[GroupRelay](./TYPES.md#grouprelay)]
|
||||
- relaysChanged: bool
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupRelayUpdated
|
||||
|
||||
Group relay member updated.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupRelayUpdated"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
- groupRelay: [GroupRelay](./TYPES.md#grouprelay)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## File events
|
||||
|
||||
Bots that send or receive files may process these events to track delivery status and to process completion.
|
||||
|
||||
Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile](./COMMANDS.md#receivefile) or [APIDeleteMemberChatItem](./COMMANDS.md#apideletememberchatitem)) when processing [NewChatItems](#newchatitems) event.
|
||||
|
||||
Bots that need to send files should use [APISendMessages](./COMMANDS.md#apisendmessages) command.
|
||||
|
||||
|
||||
### RcvFileDescrReady
|
||||
|
||||
File is ready to be received.
|
||||
|
||||
This event is useful for processing sender file servers and monitoring file reception progress.
|
||||
|
||||
[ReceiveFile](./COMMANDS.md#receivefile) command can be used before this event.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileDescrReady"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
- rcvFileTransfer: [RcvFileTransfer](./TYPES.md#rcvfiletransfer)
|
||||
- rcvFileDescr: [RcvFileDescr](./TYPES.md#rcvfiledescr)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileComplete
|
||||
|
||||
File reception is competed.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileComplete"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### SndFileCompleteXFTP
|
||||
|
||||
File upload is competed.
|
||||
|
||||
**Record type**:
|
||||
- type: "sndFileCompleteXFTP"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
- fileTransferMeta: [FileTransferMeta](./TYPES.md#filetransfermeta)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileStart
|
||||
|
||||
File reception started. This event will be sent after [CEvtRcvFileDescrReady](#rcvfiledescrready) event.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileStart"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileSndCancelled
|
||||
|
||||
File was cancelled by the sender. This event may be sent instead of [CEvtRcvFileDescrReady](#rcvfiledescrready) event.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileSndCancelled"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
- rcvFileTransfer: [RcvFileTransfer](./TYPES.md#rcvfiletransfer)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileAccepted
|
||||
|
||||
This event will be sent when file is automatically accepted because of CLI option.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileAccepted"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem: [AChatItem](./TYPES.md#achatitem)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileError
|
||||
|
||||
Error receiving file.
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileError"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem_: [AChatItem](./TYPES.md#achatitem)?
|
||||
- agentError: [AgentErrorType](./TYPES.md#agenterrortype)
|
||||
- rcvFileTransfer: [RcvFileTransfer](./TYPES.md#rcvfiletransfer)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RcvFileWarning
|
||||
|
||||
Warning when receiving file. It can happen when CLI settings do not allow to connect to file server(s).
|
||||
|
||||
**Record type**:
|
||||
- type: "rcvFileWarning"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem_: [AChatItem](./TYPES.md#achatitem)?
|
||||
- agentError: [AgentErrorType](./TYPES.md#agenterrortype)
|
||||
- rcvFileTransfer: [RcvFileTransfer](./TYPES.md#rcvfiletransfer)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### SndFileError
|
||||
|
||||
Error sending file.
|
||||
|
||||
**Record type**:
|
||||
- type: "sndFileError"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem_: [AChatItem](./TYPES.md#achatitem)?
|
||||
- fileTransferMeta: [FileTransferMeta](./TYPES.md#filetransfermeta)
|
||||
- errorMessage: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
### SndFileWarning
|
||||
|
||||
Warning when sending file.
|
||||
|
||||
**Record type**:
|
||||
- type: "sndFileWarning"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- chatItem_: [AChatItem](./TYPES.md#achatitem)?
|
||||
- fileTransferMeta: [FileTransferMeta](./TYPES.md#filetransfermeta)
|
||||
- errorMessage: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Connection progress events
|
||||
|
||||
Bots may use these events to track progress of connections for monitoring or debugging.
|
||||
|
||||
|
||||
### AcceptingContactRequest
|
||||
|
||||
Automatically accepting contact request via bot's SimpleX address with auto-accept enabled.
|
||||
|
||||
**Record type**:
|
||||
- type: "acceptingContactRequest"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### AcceptingBusinessRequest
|
||||
|
||||
Automatically accepting contact request via bot's business address.
|
||||
|
||||
**Record type**:
|
||||
- type: "acceptingBusinessRequest"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ContactConnecting
|
||||
|
||||
Contact confirmed connection.
|
||||
|
||||
Sent when contact started connecting via bot's 1-time invitation link or when bot connects to another SimpleX address.
|
||||
|
||||
**Record type**:
|
||||
- type: "contactConnecting"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- contact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### BusinessLinkConnecting
|
||||
|
||||
Contact confirmed connection.
|
||||
|
||||
Sent when bot connects to another business address.
|
||||
|
||||
**Record type**:
|
||||
- type: "businessLinkConnecting"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- hostMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- fromContact: [Contact](./TYPES.md#contact)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### JoinedGroupMemberConnecting
|
||||
|
||||
Group member is announced to the group and will be connecting to bot.
|
||||
|
||||
**Record type**:
|
||||
- type: "joinedGroupMemberConnecting"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- hostMember: [GroupMember](./TYPES.md#groupmember)
|
||||
- member: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### GroupLinkConnecting
|
||||
|
||||
Sent when bot joins group via another user link.
|
||||
|
||||
**Record type**:
|
||||
- type: "groupLinkConnecting"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- groupInfo: [GroupInfo](./TYPES.md#groupinfo)
|
||||
- hostMember: [GroupMember](./TYPES.md#groupmember)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Network connection events
|
||||
|
||||
|
||||
|
||||
|
||||
### HostConnected
|
||||
|
||||
Messaging or file server connected
|
||||
|
||||
**Record type**:
|
||||
- type: "hostConnected"
|
||||
- protocol: string
|
||||
- transportHost: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
### HostDisconnected
|
||||
|
||||
Messaging or file server disconnected
|
||||
|
||||
**Record type**:
|
||||
- type: "hostDisconnected"
|
||||
- protocol: string
|
||||
- transportHost: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
### SubscriptionStatus
|
||||
|
||||
Messaging subscription status changed
|
||||
|
||||
**Record type**:
|
||||
- type: "subscriptionStatus"
|
||||
- server: string
|
||||
- subscriptionStatus: [SubscriptionStatus](./TYPES.md#subscriptionstatus)
|
||||
- connections: [string]
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Service events
|
||||
|
||||
Bots with a double ratchet address, started with service request processing enabled, can answer service requests - a single request with a single response (RPC).
|
||||
|
||||
|
||||
### ServiceRequest
|
||||
|
||||
Service request received.
|
||||
|
||||
The request needs to be answered using [APISendServiceResponse](./COMMANDS.md#apisendserviceresponse) command.
|
||||
|
||||
**Record type**:
|
||||
- type: "serviceRequest"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- requestId: string
|
||||
- signerKey: string?
|
||||
- requestData: JSONObject
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ServiceReplySent
|
||||
|
||||
Service reply was sent (delivered to the server).
|
||||
|
||||
Correlate `connectionId` with the connection ID from the response to [APISendServiceResponse](./COMMANDS.md#apisendserviceresponse) to learn when the reply is delivered.
|
||||
|
||||
**Record type**:
|
||||
- type: "serviceReplySent"
|
||||
- connectionId: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Remote control events
|
||||
|
||||
Bots that act as remote control hosts receive these events during the remote control session lifecycle.
|
||||
|
||||
|
||||
### RemoteCtrlSessionCode
|
||||
|
||||
Remote controller session code ready for verification.
|
||||
|
||||
Use [VerifyRemoteCtrlSession](./COMMANDS.md#verifyremotectrlsession) to complete the connection.
|
||||
|
||||
**Record type**:
|
||||
- type: "remoteCtrlSessionCode"
|
||||
- remoteCtrl_: [RemoteCtrlInfo](./TYPES.md#remotectrlinfo)?
|
||||
- sessionCode: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
### RemoteCtrlStopped
|
||||
|
||||
Remote controller session stopped.
|
||||
|
||||
**Record type**:
|
||||
- type: "remoteCtrlStopped"
|
||||
- rcsState: [RemoteCtrlSessionState](./TYPES.md#remotectrlsessionstate)
|
||||
- rcStopReason: [RemoteCtrlStopReason](./TYPES.md#remotectrlstopreason)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Error events
|
||||
|
||||
Bots may log these events for debugging. There will be many error events - this does NOT indicate a malfunction - e.g., they may happen because of bad network connectivity, or because messages may be delivered to deleted chats for a short period of time (they will be ignored).
|
||||
|
||||
|
||||
### MessageError
|
||||
|
||||
Message error.
|
||||
|
||||
**Record type**:
|
||||
- type: "messageError"
|
||||
- user: [User](./TYPES.md#user)
|
||||
- severity: string
|
||||
- errorMessage: string
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatError
|
||||
|
||||
Chat error (only used in WebSockets API).
|
||||
|
||||
**Record type**:
|
||||
- type: "chatError"
|
||||
- chatError: [ChatError](./TYPES.md#chaterror)
|
||||
|
||||
---
|
||||
|
||||
|
||||
### ChatErrors
|
||||
|
||||
Chat errors.
|
||||
|
||||
**Record type**:
|
||||
- type: "chatErrors"
|
||||
- chatErrors: [[ChatError](./TYPES.md#chaterror)]
|
||||
|
||||
---
|
||||
-4712
File diff suppressed because it is too large.
Load diff
@@ -1,938 +0,0 @@
|
||||
// API Commands
|
||||
// This file is generated automatically.
|
||||
|
||||
import * as T from "./types"
|
||||
|
||||
import {CR} from "./responses"
|
||||
|
||||
// Address commands
|
||||
// Bots can use these commands to automatically check and create address when initialized
|
||||
|
||||
// Create bot address.
|
||||
// Network usage: interactive.
|
||||
export interface APICreateMyAddress {
|
||||
userId: number // int64
|
||||
pqRatchet?: boolean
|
||||
}
|
||||
|
||||
export namespace APICreateMyAddress {
|
||||
export type Response = CR.UserContactLinkCreated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APICreateMyAddress): string {
|
||||
return '/_address ' + self.userId + (typeof self.pqRatchet == 'boolean' ? ' pq_ratchet=' + (self.pqRatchet ? 'on' : 'off') : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Delete bot address.
|
||||
// Network usage: background.
|
||||
export interface APIDeleteMyAddress {
|
||||
userId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIDeleteMyAddress {
|
||||
export type Response = CR.UserContactLinkDeleted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteMyAddress): string {
|
||||
return '/_delete_address ' + self.userId
|
||||
}
|
||||
}
|
||||
|
||||
// Get bot address and settings.
|
||||
// Network usage: no.
|
||||
export interface APIShowMyAddress {
|
||||
userId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIShowMyAddress {
|
||||
export type Response = CR.UserContactLink | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIShowMyAddress): string {
|
||||
return '/_show_address ' + self.userId
|
||||
}
|
||||
}
|
||||
|
||||
// Add address to bot profile.
|
||||
// Network usage: interactive.
|
||||
export interface APISetProfileAddress {
|
||||
userId: number // int64
|
||||
enable: boolean
|
||||
}
|
||||
|
||||
export namespace APISetProfileAddress {
|
||||
export type Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetProfileAddress): string {
|
||||
return '/_profile_address ' + self.userId + ' ' + (self.enable ? 'on' : 'off')
|
||||
}
|
||||
}
|
||||
|
||||
// Set bot address settings.
|
||||
// Network usage: interactive.
|
||||
export interface APISetAddressSettings {
|
||||
userId: number // int64
|
||||
pqRatchet?: boolean
|
||||
settings: T.AddressSettings
|
||||
}
|
||||
|
||||
export namespace APISetAddressSettings {
|
||||
export type Response = CR.UserContactLinkUpdated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetAddressSettings): string {
|
||||
return '/_address_settings ' + self.userId + (typeof self.pqRatchet == 'boolean' ? ' pq_ratchet=' + (self.pqRatchet ? 'on' : 'off') : '') + ' ' + JSON.stringify(self.settings)
|
||||
}
|
||||
}
|
||||
|
||||
// Message commands
|
||||
// Commands to send, update, delete, moderate messages and set message reactions
|
||||
|
||||
// Send messages.
|
||||
// Network usage: background.
|
||||
export interface APISendMessages {
|
||||
sendRef: T.ChatRef
|
||||
liveMessage: boolean
|
||||
ttl?: number // int
|
||||
signMessages: boolean
|
||||
composedMessages: T.ComposedMessage[] // non-empty
|
||||
}
|
||||
|
||||
export namespace APISendMessages {
|
||||
export type Response = CR.NewChatItems | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISendMessages): string {
|
||||
return '/_send ' + T.ChatRef.cmdString(self.sendRef) + (self.liveMessage ? ' live=on' : '') + (self.ttl ? ' ttl=' + self.ttl : '') + (self.signMessages ? ' sign=on' : '') + ' json ' + JSON.stringify(self.composedMessages)
|
||||
}
|
||||
}
|
||||
|
||||
// Update message.
|
||||
// Network usage: background.
|
||||
export interface APIUpdateChatItem {
|
||||
chatRef: T.ChatRef
|
||||
chatItemId: number // int64
|
||||
liveMessage: boolean
|
||||
updatedMessage: T.UpdatedMessage
|
||||
}
|
||||
|
||||
export namespace APIUpdateChatItem {
|
||||
export type Response = CR.ChatItemUpdated | CR.ChatItemNotChanged | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIUpdateChatItem): string {
|
||||
return '/_update item ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemId + (self.liveMessage ? ' live=on' : '') + ' json ' + JSON.stringify(self.updatedMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete message.
|
||||
// Network usage: background.
|
||||
export interface APIDeleteChatItem {
|
||||
chatRef: T.ChatRef
|
||||
chatItemIds: number[] // int64, non-empty
|
||||
deleteMode: T.CIDeleteMode
|
||||
}
|
||||
|
||||
export namespace APIDeleteChatItem {
|
||||
export type Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteChatItem): string {
|
||||
return '/_delete item ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemIds.join(',') + ' ' + self.deleteMode
|
||||
}
|
||||
}
|
||||
|
||||
// Moderate message. Requires Moderator role (and higher than message author's).
|
||||
// Network usage: background.
|
||||
export interface APIDeleteMemberChatItem {
|
||||
groupId: number // int64
|
||||
chatItemIds: number[] // int64, non-empty
|
||||
}
|
||||
|
||||
export namespace APIDeleteMemberChatItem {
|
||||
export type Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteMemberChatItem): string {
|
||||
return '/_delete member item #' + self.groupId + ' ' + self.chatItemIds.join(',')
|
||||
}
|
||||
}
|
||||
|
||||
// Add/remove message reaction.
|
||||
// Network usage: background.
|
||||
export interface APIChatItemReaction {
|
||||
chatRef: T.ChatRef
|
||||
chatItemId: number // int64
|
||||
add: boolean
|
||||
reaction: T.MsgReaction
|
||||
}
|
||||
|
||||
export namespace APIChatItemReaction {
|
||||
export type Response = CR.ChatItemReaction | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIChatItemReaction): string {
|
||||
return '/_reaction ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemId + ' ' + (self.add ? 'on' : 'off') + ' ' + JSON.stringify(self.reaction)
|
||||
}
|
||||
}
|
||||
|
||||
// Share user address card
|
||||
// Network usage: no.
|
||||
export interface APIShareMyAddress {
|
||||
toSendRef: T.ChatRef
|
||||
}
|
||||
|
||||
export namespace APIShareMyAddress {
|
||||
export type Response = CR.ChatMsgContent
|
||||
|
||||
export function cmdString(self: APIShareMyAddress): string {
|
||||
return '/_share address ' + T.ChatRef.cmdString(self.toSendRef)
|
||||
}
|
||||
}
|
||||
|
||||
// Share channel address
|
||||
// Network usage: no.
|
||||
export interface APIShareChatMsgContent {
|
||||
shareChatRef: T.ChatRef
|
||||
toSendRef: T.ChatRef
|
||||
}
|
||||
|
||||
export namespace APIShareChatMsgContent {
|
||||
export type Response = CR.ChatMsgContent
|
||||
|
||||
export function cmdString(self: APIShareChatMsgContent): string {
|
||||
return '/_share chat content ' + T.ChatRef.cmdString(self.shareChatRef) + ' ' + T.ChatRef.cmdString(self.toSendRef)
|
||||
}
|
||||
}
|
||||
|
||||
// File commands
|
||||
// Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.
|
||||
|
||||
// Receive file.
|
||||
// Network usage: no.
|
||||
export interface ReceiveFile {
|
||||
fileId: number // int64
|
||||
userApprovedRelays: boolean
|
||||
storeEncrypted?: boolean
|
||||
fileInline?: boolean
|
||||
filePath?: string
|
||||
}
|
||||
|
||||
export namespace ReceiveFile {
|
||||
export type Response = CR.RcvFileAccepted | CR.RcvFileAcceptedSndCancelled | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: ReceiveFile): string {
|
||||
return '/freceive ' + self.fileId + (self.userApprovedRelays ? ' approved_relays=on' : '') + (typeof self.storeEncrypted == 'boolean' ? ' encrypt=' + (self.storeEncrypted ? 'on' : 'off') : '') + (typeof self.fileInline == 'boolean' ? ' inline=' + (self.fileInline ? 'on' : 'off') : '') + (self.filePath ? ' ' + self.filePath : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel file.
|
||||
// Network usage: background.
|
||||
export interface CancelFile {
|
||||
fileId: number // int64
|
||||
}
|
||||
|
||||
export namespace CancelFile {
|
||||
export type Response = CR.SndFileCancelled | CR.RcvFileCancelled | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: CancelFile): string {
|
||||
return '/fcancel ' + self.fileId
|
||||
}
|
||||
}
|
||||
|
||||
// Group commands
|
||||
// Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.
|
||||
|
||||
// Add contact to group. Requires bot to have Admin role.
|
||||
// Network usage: interactive.
|
||||
export interface APIAddMember {
|
||||
groupId: number // int64
|
||||
contactId: number // int64
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export namespace APIAddMember {
|
||||
export type Response = CR.SentGroupInvitation | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAddMember): string {
|
||||
return '/_add #' + self.groupId + ' ' + self.contactId + ' ' + self.memberRole
|
||||
}
|
||||
}
|
||||
|
||||
// Join group.
|
||||
// Network usage: interactive.
|
||||
export interface APIJoinGroup {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIJoinGroup {
|
||||
export type Response = CR.UserAcceptedGroupSent | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIJoinGroup): string {
|
||||
return '/_join #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Accept group member. Requires Admin role.
|
||||
// Network usage: background.
|
||||
export interface APIAcceptMember {
|
||||
groupId: number // int64
|
||||
groupMemberId: number // int64
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export namespace APIAcceptMember {
|
||||
export type Response = CR.MemberAccepted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAcceptMember): string {
|
||||
return '/_accept member #' + self.groupId + ' ' + self.groupMemberId + ' ' + self.memberRole
|
||||
}
|
||||
}
|
||||
|
||||
// Set members role. Requires Admin role.
|
||||
// Network usage: background.
|
||||
export interface APIMembersRole {
|
||||
groupId: number // int64
|
||||
groupMemberIds: number[] // int64, non-empty
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export namespace APIMembersRole {
|
||||
export type Response = CR.MembersRoleUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIMembersRole): string {
|
||||
return '/_member role #' + self.groupId + ' ' + self.groupMemberIds.join(',') + ' ' + self.memberRole
|
||||
}
|
||||
}
|
||||
|
||||
// Block members. Requires Moderator role.
|
||||
// Network usage: background.
|
||||
export interface APIBlockMembersForAll {
|
||||
groupId: number // int64
|
||||
groupMemberIds: number[] // int64, non-empty
|
||||
blocked: boolean
|
||||
}
|
||||
|
||||
export namespace APIBlockMembersForAll {
|
||||
export type Response = CR.MembersBlockedForAllUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIBlockMembersForAll): string {
|
||||
return '/_block #' + self.groupId + ' ' + self.groupMemberIds.join(',') + ' blocked=' + (self.blocked ? 'on' : 'off')
|
||||
}
|
||||
}
|
||||
|
||||
// Remove members. Requires Admin role.
|
||||
// Network usage: background.
|
||||
export interface APIRemoveMembers {
|
||||
groupId: number // int64
|
||||
groupMemberIds: number[] // int64, non-empty
|
||||
withMessages: boolean
|
||||
}
|
||||
|
||||
export namespace APIRemoveMembers {
|
||||
export type Response = CR.UserDeletedMembers | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIRemoveMembers): string {
|
||||
return '/_remove #' + self.groupId + ' ' + self.groupMemberIds.join(',') + (self.withMessages ? ' messages=on' : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Leave group.
|
||||
// Network usage: background.
|
||||
export interface APILeaveGroup {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APILeaveGroup {
|
||||
export type Response = CR.LeftMemberUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APILeaveGroup): string {
|
||||
return '/_leave #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Get group members.
|
||||
// Network usage: no.
|
||||
export interface APIListMembers {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIListMembers {
|
||||
export type Response = CR.GroupMembers | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIListMembers): string {
|
||||
return '/_members #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Create group.
|
||||
// Network usage: no.
|
||||
export interface APINewGroup {
|
||||
userId: number // int64
|
||||
incognito: boolean
|
||||
groupProfile: T.GroupProfile
|
||||
}
|
||||
|
||||
export namespace APINewGroup {
|
||||
export type Response = CR.GroupCreated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APINewGroup): string {
|
||||
return '/_group ' + self.userId + (self.incognito ? ' incognito=on' : '') + ' ' + JSON.stringify(self.groupProfile)
|
||||
}
|
||||
}
|
||||
|
||||
// Create public group.
|
||||
// Network usage: interactive.
|
||||
export interface APINewPublicGroup {
|
||||
userId: number // int64
|
||||
incognito: boolean
|
||||
relayIds: number[] // int64, non-empty
|
||||
groupProfile: T.GroupProfile
|
||||
}
|
||||
|
||||
export namespace APINewPublicGroup {
|
||||
export type Response = CR.PublicGroupCreated | CR.PublicGroupCreationFailed | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APINewPublicGroup): string {
|
||||
return '/_public group ' + self.userId + (self.incognito ? ' incognito=on' : '') + ' ' + self.relayIds.join(',') + ' ' + JSON.stringify(self.groupProfile)
|
||||
}
|
||||
}
|
||||
|
||||
// Get group relays.
|
||||
// Network usage: no.
|
||||
export interface APIGetGroupRelays {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIGetGroupRelays {
|
||||
export type Response = CR.GroupRelays | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIGetGroupRelays): string {
|
||||
return '/_get relays #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Add relays to group.
|
||||
// Network usage: interactive.
|
||||
export interface APIAddGroupRelays {
|
||||
groupId: number // int64
|
||||
relayIds: number[] // int64, non-empty
|
||||
}
|
||||
|
||||
export namespace APIAddGroupRelays {
|
||||
export type Response = CR.GroupRelaysAdded | CR.GroupRelaysAddFailed | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAddGroupRelays): string {
|
||||
return '/_add relays #' + self.groupId + ' ' + self.relayIds.join(',')
|
||||
}
|
||||
}
|
||||
|
||||
// Clear relay rejection for a channel (relay operator).
|
||||
// Network usage: background.
|
||||
export interface APIAllowRelayGroup {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIAllowRelayGroup {
|
||||
export type Response = CR.RelayGroupAllowed | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAllowRelayGroup): string {
|
||||
return '/_relay allow #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Update group profile.
|
||||
// Network usage: background.
|
||||
export interface APIUpdateGroupProfile {
|
||||
groupId: number // int64
|
||||
groupProfile: T.GroupProfile
|
||||
}
|
||||
|
||||
export namespace APIUpdateGroupProfile {
|
||||
export type Response = CR.GroupUpdated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIUpdateGroupProfile): string {
|
||||
return '/_group_profile #' + self.groupId + ' ' + JSON.stringify(self.groupProfile)
|
||||
}
|
||||
}
|
||||
|
||||
// Verify group domain
|
||||
// Network usage: interactive.
|
||||
export interface APIVerifyGroupDomain {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIVerifyGroupDomain {
|
||||
export type Response = CR.GroupDomainVerified
|
||||
|
||||
export function cmdString(self: APIVerifyGroupDomain): string {
|
||||
return '/_verify domain #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Group link commands
|
||||
// These commands can be used by bots that manage multiple public groups
|
||||
|
||||
// Create group link.
|
||||
// Network usage: interactive.
|
||||
export interface APICreateGroupLink {
|
||||
groupId: number // int64
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export namespace APICreateGroupLink {
|
||||
export type Response = CR.GroupLinkCreated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APICreateGroupLink): string {
|
||||
return '/_create link #' + self.groupId + ' ' + self.memberRole
|
||||
}
|
||||
}
|
||||
|
||||
// Set member role for group link.
|
||||
// Network usage: no.
|
||||
export interface APIGroupLinkMemberRole {
|
||||
groupId: number // int64
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export namespace APIGroupLinkMemberRole {
|
||||
export type Response = CR.GroupLink | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIGroupLinkMemberRole): string {
|
||||
return '/_set link role #' + self.groupId + ' ' + self.memberRole
|
||||
}
|
||||
}
|
||||
|
||||
// Delete group link.
|
||||
// Network usage: background.
|
||||
export interface APIDeleteGroupLink {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIDeleteGroupLink {
|
||||
export type Response = CR.GroupLinkDeleted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteGroupLink): string {
|
||||
return '/_delete link #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Get group link.
|
||||
// Network usage: no.
|
||||
export interface APIGetGroupLink {
|
||||
groupId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIGetGroupLink {
|
||||
export type Response = CR.GroupLink | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIGetGroupLink): string {
|
||||
return '/_get link #' + self.groupId
|
||||
}
|
||||
}
|
||||
|
||||
// Connection commands
|
||||
// These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.
|
||||
|
||||
// Create 1-time invitation link.
|
||||
// Network usage: interactive.
|
||||
export interface APIAddContact {
|
||||
userId: number // int64
|
||||
incognito: boolean
|
||||
}
|
||||
|
||||
export namespace APIAddContact {
|
||||
export type Response = CR.Invitation | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAddContact): string {
|
||||
return '/_connect ' + self.userId + (self.incognito ? ' incognito=on' : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Determine SimpleX link type and if the bot is already connected via this link or name.
|
||||
// Network usage: interactive.
|
||||
export interface APIConnectPlan {
|
||||
userId: number // int64
|
||||
connectTarget?: string
|
||||
resolveMode: T.PlanResolveMode
|
||||
linkOwnerSig?: T.LinkOwnerSig
|
||||
}
|
||||
|
||||
export namespace APIConnectPlan {
|
||||
export type Response = CR.ConnectionPlan | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIConnectPlan): string {
|
||||
return '/_connect plan ' + self.userId + ' ' + self.connectTarget
|
||||
}
|
||||
}
|
||||
|
||||
// Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link.
|
||||
// Network usage: interactive.
|
||||
export interface APIConnect {
|
||||
userId: number // int64
|
||||
incognito: boolean
|
||||
preparedLink_?: T.CreatedConnLink
|
||||
}
|
||||
|
||||
export namespace APIConnect {
|
||||
export type Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIConnect): string {
|
||||
return '/_connect ' + self.userId + (self.incognito ? ' incognito=on' : '') + (self.preparedLink_ ? ' ' + T.CreatedConnLink.cmdString(self.preparedLink_) : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Connect via SimpleX link or name as string in the active user profile.
|
||||
// Network usage: interactive.
|
||||
export interface Connect {
|
||||
incognito: boolean
|
||||
connTarget_?: string
|
||||
}
|
||||
|
||||
export namespace Connect {
|
||||
export type Response =
|
||||
| CR.SentConfirmation
|
||||
| CR.ContactAlreadyExists
|
||||
| CR.SentInvitation
|
||||
| CR.ConnectionPlan
|
||||
| CR.SentInvitationToContact
|
||||
| CR.StartedConnectionToContact
|
||||
| CR.StartedConnectionToGroup
|
||||
| CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: Connect): string {
|
||||
return '/connect' + (self.connTarget_ ? ' ' + self.connTarget_ : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Accept contact request.
|
||||
// Network usage: interactive.
|
||||
export interface APIAcceptContact {
|
||||
contactReqId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIAcceptContact {
|
||||
export type Response = CR.AcceptingContactRequest | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIAcceptContact): string {
|
||||
return '/_accept ' + self.contactReqId
|
||||
}
|
||||
}
|
||||
|
||||
// Reject contact request. The user who sent the request is **not notified**.
|
||||
// Network usage: no.
|
||||
export interface APIRejectContact {
|
||||
contactReqId: number // int64
|
||||
notify: boolean
|
||||
}
|
||||
|
||||
export namespace APIRejectContact {
|
||||
export type Response = CR.ContactRequestRejected | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIRejectContact): string {
|
||||
return '/_reject ' + self.contactReqId
|
||||
}
|
||||
}
|
||||
|
||||
// Chat commands
|
||||
// Commands to list and delete conversations.
|
||||
|
||||
// Get contacts.
|
||||
// Network usage: no.
|
||||
export interface APIListContacts {
|
||||
userId: number // int64
|
||||
}
|
||||
|
||||
export namespace APIListContacts {
|
||||
export type Response = CR.ContactsList | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIListContacts): string {
|
||||
return '/_contacts ' + self.userId
|
||||
}
|
||||
}
|
||||
|
||||
// Get groups.
|
||||
// Network usage: no.
|
||||
export interface APIListGroups {
|
||||
userId: number // int64
|
||||
contactId_?: number // int64
|
||||
search?: string
|
||||
}
|
||||
|
||||
export namespace APIListGroups {
|
||||
export type Response = CR.GroupsList | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIListGroups): string {
|
||||
return '/_groups ' + self.userId + (self.contactId_ ? ' @' + self.contactId_ : '') + (self.search ? ' ' + self.search : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Get chat previews. Supports time-based pagination — use this instead of APIListContacts / APIListGroups when scanning at scale (those load every record into memory and fail on large databases).
|
||||
// Network usage: no.
|
||||
export interface APIGetChats {
|
||||
userId: number // int64
|
||||
pendingConnections: boolean
|
||||
pagination?: T.PaginationByTime
|
||||
query: T.ChatListQuery
|
||||
}
|
||||
|
||||
export namespace APIGetChats {
|
||||
export type Response = CR.ApiChats | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIGetChats): string {
|
||||
return '/_get chats ' + self.userId + (self.pendingConnections ? ' pcc=on' : '') + (self.pagination ? ' ' + T.PaginationByTime.cmdString(self.pagination) : '') + ' ' + JSON.stringify(self.query)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete chat.
|
||||
// Network usage: background.
|
||||
export interface APIDeleteChat {
|
||||
chatRef: T.ChatRef
|
||||
chatDeleteMode: T.ChatDeleteMode
|
||||
}
|
||||
|
||||
export namespace APIDeleteChat {
|
||||
export type Response = CR.ContactDeleted | CR.ContactConnectionDeleted | CR.GroupDeletedUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteChat): string {
|
||||
return '/_delete ' + T.ChatRef.cmdString(self.chatRef) + ' ' + T.ChatDeleteMode.cmdString(self.chatDeleteMode)
|
||||
}
|
||||
}
|
||||
|
||||
// Set group custom data.
|
||||
// Network usage: no.
|
||||
export interface APISetGroupCustomData {
|
||||
groupId: number // int64
|
||||
customData?: object
|
||||
}
|
||||
|
||||
export namespace APISetGroupCustomData {
|
||||
export type Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetGroupCustomData): string {
|
||||
return '/_set custom #' + self.groupId + (self.customData ? ' ' + JSON.stringify(self.customData) : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Set contact custom data.
|
||||
// Network usage: no.
|
||||
export interface APISetContactCustomData {
|
||||
contactId: number // int64
|
||||
customData?: object
|
||||
}
|
||||
|
||||
export namespace APISetContactCustomData {
|
||||
export type Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetContactCustomData): string {
|
||||
return '/_set custom @' + self.contactId + (self.customData ? ' ' + JSON.stringify(self.customData) : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Set auto-accept member contacts.
|
||||
// Network usage: no.
|
||||
export interface APISetUserAutoAcceptMemberContacts {
|
||||
userId: number // int64
|
||||
onOff: boolean
|
||||
}
|
||||
|
||||
export namespace APISetUserAutoAcceptMemberContacts {
|
||||
export type Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetUserAutoAcceptMemberContacts): string {
|
||||
return '/_set accept member contacts ' + self.userId + ' ' + (self.onOff ? 'on' : 'off')
|
||||
}
|
||||
}
|
||||
|
||||
// Set auto-accept group invitations.
|
||||
// Network usage: no.
|
||||
export interface APISetUserAutoAcceptGroupInvitations {
|
||||
userId: number // int64
|
||||
onOff: boolean
|
||||
}
|
||||
|
||||
export namespace APISetUserAutoAcceptGroupInvitations {
|
||||
export type Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetUserAutoAcceptGroupInvitations): string {
|
||||
return '/_set accept group invitations ' + self.userId + ' ' + (self.onOff ? 'on' : 'off')
|
||||
}
|
||||
}
|
||||
|
||||
// User profile commands
|
||||
// Most bots don't need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).
|
||||
|
||||
// Get active user profile.
|
||||
// Network usage: no.
|
||||
export interface ShowActiveUser {
|
||||
}
|
||||
|
||||
export namespace ShowActiveUser {
|
||||
export type Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(_self: ShowActiveUser): string {
|
||||
return '/user'
|
||||
}
|
||||
}
|
||||
|
||||
// Create new user profile.
|
||||
// Network usage: no.
|
||||
export interface CreateActiveUser {
|
||||
newUser: T.NewUser
|
||||
}
|
||||
|
||||
export namespace CreateActiveUser {
|
||||
export type Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: CreateActiveUser): string {
|
||||
return '/_create user ' + JSON.stringify(self.newUser)
|
||||
}
|
||||
}
|
||||
|
||||
// Get all user profiles.
|
||||
// Network usage: no.
|
||||
export interface ListUsers {
|
||||
}
|
||||
|
||||
export namespace ListUsers {
|
||||
export type Response = CR.UsersList | CR.ChatCmdError
|
||||
|
||||
export function cmdString(_self: ListUsers): string {
|
||||
return '/users'
|
||||
}
|
||||
}
|
||||
|
||||
// Set active user profile.
|
||||
// Network usage: no.
|
||||
export interface APISetActiveUser {
|
||||
userId: number // int64
|
||||
viewPwd?: string
|
||||
}
|
||||
|
||||
export namespace APISetActiveUser {
|
||||
export type Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetActiveUser): string {
|
||||
return '/_user ' + self.userId + (self.viewPwd ? ' ' + JSON.stringify(self.viewPwd) : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Delete user profile.
|
||||
// Network usage: background.
|
||||
export interface APIDeleteUser {
|
||||
userId: number // int64
|
||||
delSMPQueues: boolean
|
||||
viewPwd?: string
|
||||
}
|
||||
|
||||
export namespace APIDeleteUser {
|
||||
export type Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIDeleteUser): string {
|
||||
return '/_delete user ' + self.userId + ' del_smp=' + (self.delSMPQueues ? 'on' : 'off') + (self.viewPwd ? ' ' + JSON.stringify(self.viewPwd) : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Update user profile.
|
||||
// Network usage: background.
|
||||
export interface APIUpdateProfile {
|
||||
userId: number // int64
|
||||
profile: T.Profile
|
||||
}
|
||||
|
||||
export namespace APIUpdateProfile {
|
||||
export type Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APIUpdateProfile): string {
|
||||
return '/_profile ' + self.userId + ' ' + JSON.stringify(self.profile)
|
||||
}
|
||||
}
|
||||
|
||||
// Configure chat preference overrides for the contact.
|
||||
// Network usage: background.
|
||||
export interface APISetContactPrefs {
|
||||
contactId: number // int64
|
||||
preferences: T.Preferences
|
||||
}
|
||||
|
||||
export namespace APISetContactPrefs {
|
||||
export type Response = CR.ContactPrefsUpdated | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISetContactPrefs): string {
|
||||
return '/_set prefs @' + self.contactId + ' ' + JSON.stringify(self.preferences)
|
||||
}
|
||||
}
|
||||
|
||||
// Service commands
|
||||
// Bots with a double ratchet address can answer service requests.
|
||||
|
||||
// Send a reply to a received service request. Returns the connection ID that correlates the reply delivery event.
|
||||
// Network usage: background.
|
||||
export interface APISendServiceResponse {
|
||||
userId: number // int64
|
||||
requestId: string
|
||||
responseData: object
|
||||
}
|
||||
|
||||
export namespace APISendServiceResponse {
|
||||
export type Response = CR.ServiceReplyAccepted | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: APISendServiceResponse): string {
|
||||
return '/_service_response ' + self.userId + ' ' + self.requestId + ' ' + JSON.stringify(self.responseData)
|
||||
}
|
||||
}
|
||||
|
||||
// Chat management
|
||||
// These commands should not be used with CLI-based bots
|
||||
|
||||
// Start chat controller.
|
||||
// Network usage: no.
|
||||
export interface StartChat {
|
||||
mainApp: boolean
|
||||
enableSndFiles: boolean
|
||||
serviceRequests: boolean
|
||||
}
|
||||
|
||||
export namespace StartChat {
|
||||
export type Response = CR.ChatStarted | CR.ChatRunning
|
||||
|
||||
export function cmdString(self: StartChat): string {
|
||||
return '/_start main=' + (self.mainApp ? 'on' : 'off') + (!self.enableSndFiles ? ' snd_files=off' : '') + (self.serviceRequests ? ' service_requests=on' : '')
|
||||
}
|
||||
}
|
||||
|
||||
// Stop chat controller.
|
||||
// Network usage: no.
|
||||
export interface APIStopChat {
|
||||
}
|
||||
|
||||
export namespace APIStopChat {
|
||||
export type Response = CR.ChatStopped
|
||||
|
||||
export function cmdString(_self: APIStopChat): string {
|
||||
return '/_stop'
|
||||
}
|
||||
}
|
||||
|
||||
// Remote control commands
|
||||
// Allows a bot to accept an incoming remote control session from a SimpleX Desktop client, giving the desktop live access to the bot's SimpleX instance.
|
||||
|
||||
// Connect to a remote controller using an OOB invitation link.
|
||||
// Network usage: interactive.
|
||||
export interface ConnectRemoteCtrl {
|
||||
remoteInvitation: string
|
||||
}
|
||||
|
||||
export namespace ConnectRemoteCtrl {
|
||||
export type Response = CR.RemoteCtrlConnecting | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: ConnectRemoteCtrl): string {
|
||||
return '/crc ' + self.remoteInvitation
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the remote controller session code to complete the connection.
|
||||
// Network usage: no.
|
||||
export interface VerifyRemoteCtrlSession {
|
||||
sessionCode: string
|
||||
}
|
||||
|
||||
export namespace VerifyRemoteCtrlSession {
|
||||
export type Response = CR.RemoteCtrlConnected | CR.ChatCmdError
|
||||
|
||||
export function cmdString(self: VerifyRemoteCtrlSession): string {
|
||||
return '/verify remote ctrl ' + self.sessionCode
|
||||
}
|
||||
}
|
||||
@@ -1,506 +0,0 @@
|
||||
// API Events
|
||||
// This file is generated automatically.
|
||||
|
||||
import * as T from "./types"
|
||||
|
||||
export type ChatEvent =
|
||||
| CEvt.ContactConnected
|
||||
| CEvt.ContactUpdated
|
||||
| CEvt.ContactDeletedByContact
|
||||
| CEvt.ReceivedContactRequest
|
||||
| CEvt.NewMemberContactReceivedInv
|
||||
| CEvt.ContactSndReady
|
||||
| CEvt.NewChatItems
|
||||
| CEvt.ChatItemReaction
|
||||
| CEvt.ChatItemsDeleted
|
||||
| CEvt.ChatItemUpdated
|
||||
| CEvt.GroupChatItemsDeleted
|
||||
| CEvt.ChatItemsStatusesUpdated
|
||||
| CEvt.ReceivedGroupInvitation
|
||||
| CEvt.UserJoinedGroup
|
||||
| CEvt.GroupUpdated
|
||||
| CEvt.JoinedGroupMember
|
||||
| CEvt.MemberRole
|
||||
| CEvt.DeletedMember
|
||||
| CEvt.LeftMember
|
||||
| CEvt.DeletedMemberUser
|
||||
| CEvt.GroupDeleted
|
||||
| CEvt.ConnectedToGroupMember
|
||||
| CEvt.MemberAcceptedByOther
|
||||
| CEvt.MemberBlockedForAll
|
||||
| CEvt.GroupMemberUpdated
|
||||
| CEvt.GroupLinkDataUpdated
|
||||
| CEvt.GroupRelayUpdated
|
||||
| CEvt.RcvFileDescrReady
|
||||
| CEvt.RcvFileComplete
|
||||
| CEvt.SndFileCompleteXFTP
|
||||
| CEvt.RcvFileStart
|
||||
| CEvt.RcvFileSndCancelled
|
||||
| CEvt.RcvFileAccepted
|
||||
| CEvt.RcvFileError
|
||||
| CEvt.RcvFileWarning
|
||||
| CEvt.SndFileError
|
||||
| CEvt.SndFileWarning
|
||||
| CEvt.AcceptingContactRequest
|
||||
| CEvt.AcceptingBusinessRequest
|
||||
| CEvt.ContactConnecting
|
||||
| CEvt.BusinessLinkConnecting
|
||||
| CEvt.JoinedGroupMemberConnecting
|
||||
| CEvt.GroupLinkConnecting
|
||||
| CEvt.HostConnected
|
||||
| CEvt.HostDisconnected
|
||||
| CEvt.SubscriptionStatus
|
||||
| CEvt.ServiceRequest
|
||||
| CEvt.ServiceReplySent
|
||||
| CEvt.RemoteCtrlSessionCode
|
||||
| CEvt.RemoteCtrlStopped
|
||||
| CEvt.MessageError
|
||||
| CEvt.ChatError
|
||||
| CEvt.ChatErrors
|
||||
|
||||
export namespace CEvt {
|
||||
export type Tag =
|
||||
| "contactConnected"
|
||||
| "contactUpdated"
|
||||
| "contactDeletedByContact"
|
||||
| "receivedContactRequest"
|
||||
| "newMemberContactReceivedInv"
|
||||
| "contactSndReady"
|
||||
| "newChatItems"
|
||||
| "chatItemReaction"
|
||||
| "chatItemsDeleted"
|
||||
| "chatItemUpdated"
|
||||
| "groupChatItemsDeleted"
|
||||
| "chatItemsStatusesUpdated"
|
||||
| "receivedGroupInvitation"
|
||||
| "userJoinedGroup"
|
||||
| "groupUpdated"
|
||||
| "joinedGroupMember"
|
||||
| "memberRole"
|
||||
| "deletedMember"
|
||||
| "leftMember"
|
||||
| "deletedMemberUser"
|
||||
| "groupDeleted"
|
||||
| "connectedToGroupMember"
|
||||
| "memberAcceptedByOther"
|
||||
| "memberBlockedForAll"
|
||||
| "groupMemberUpdated"
|
||||
| "groupLinkDataUpdated"
|
||||
| "groupRelayUpdated"
|
||||
| "rcvFileDescrReady"
|
||||
| "rcvFileComplete"
|
||||
| "sndFileCompleteXFTP"
|
||||
| "rcvFileStart"
|
||||
| "rcvFileSndCancelled"
|
||||
| "rcvFileAccepted"
|
||||
| "rcvFileError"
|
||||
| "rcvFileWarning"
|
||||
| "sndFileError"
|
||||
| "sndFileWarning"
|
||||
| "acceptingContactRequest"
|
||||
| "acceptingBusinessRequest"
|
||||
| "contactConnecting"
|
||||
| "businessLinkConnecting"
|
||||
| "joinedGroupMemberConnecting"
|
||||
| "groupLinkConnecting"
|
||||
| "hostConnected"
|
||||
| "hostDisconnected"
|
||||
| "subscriptionStatus"
|
||||
| "serviceRequest"
|
||||
| "serviceReplySent"
|
||||
| "remoteCtrlSessionCode"
|
||||
| "remoteCtrlStopped"
|
||||
| "messageError"
|
||||
| "chatError"
|
||||
| "chatErrors"
|
||||
|
||||
interface Interface {
|
||||
type: Tag
|
||||
}
|
||||
|
||||
export interface ContactConnected extends Interface {
|
||||
type: "contactConnected"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
userCustomProfile?: T.Profile
|
||||
}
|
||||
|
||||
export interface ContactUpdated extends Interface {
|
||||
type: "contactUpdated"
|
||||
user: T.User
|
||||
fromContact: T.Contact
|
||||
toContact: T.Contact
|
||||
}
|
||||
|
||||
export interface ContactDeletedByContact extends Interface {
|
||||
type: "contactDeletedByContact"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface ReceivedContactRequest extends Interface {
|
||||
type: "receivedContactRequest"
|
||||
user: T.User
|
||||
contactRequest: T.UserContactRequest
|
||||
chat_?: T.AChat
|
||||
}
|
||||
|
||||
export interface NewMemberContactReceivedInv extends Interface {
|
||||
type: "newMemberContactReceivedInv"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface ContactSndReady extends Interface {
|
||||
type: "contactSndReady"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface NewChatItems extends Interface {
|
||||
type: "newChatItems"
|
||||
user: T.User
|
||||
chatItems: T.AChatItem[]
|
||||
}
|
||||
|
||||
export interface ChatItemReaction extends Interface {
|
||||
type: "chatItemReaction"
|
||||
user: T.User
|
||||
added: boolean
|
||||
reaction: T.ACIReaction
|
||||
}
|
||||
|
||||
export interface ChatItemsDeleted extends Interface {
|
||||
type: "chatItemsDeleted"
|
||||
user: T.User
|
||||
chatItemDeletions: T.ChatItemDeletion[]
|
||||
byUser: boolean
|
||||
timed: boolean
|
||||
}
|
||||
|
||||
export interface ChatItemUpdated extends Interface {
|
||||
type: "chatItemUpdated"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface GroupChatItemsDeleted extends Interface {
|
||||
type: "groupChatItemsDeleted"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
chatItemIDs: number[] // int64
|
||||
byUser: boolean
|
||||
member_?: T.GroupMember
|
||||
}
|
||||
|
||||
export interface ChatItemsStatusesUpdated extends Interface {
|
||||
type: "chatItemsStatusesUpdated"
|
||||
user: T.User
|
||||
chatItems: T.AChatItem[]
|
||||
}
|
||||
|
||||
export interface ReceivedGroupInvitation extends Interface {
|
||||
type: "receivedGroupInvitation"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
contact: T.Contact
|
||||
fromMemberRole: T.GroupMemberRole
|
||||
memberRole: T.GroupMemberRole
|
||||
}
|
||||
|
||||
export interface UserJoinedGroup extends Interface {
|
||||
type: "userJoinedGroup"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
hostMember: T.GroupMember
|
||||
}
|
||||
|
||||
export interface GroupUpdated extends Interface {
|
||||
type: "groupUpdated"
|
||||
user: T.User
|
||||
fromGroup: T.GroupInfo
|
||||
toGroup: T.GroupInfo
|
||||
member_?: T.GroupMember
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface JoinedGroupMember extends Interface {
|
||||
type: "joinedGroupMember"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface MemberRole extends Interface {
|
||||
type: "memberRole"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
byMember: T.GroupMember
|
||||
member: T.GroupMember
|
||||
fromRole: T.GroupMemberRole
|
||||
toRole: T.GroupMemberRole
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface DeletedMember extends Interface {
|
||||
type: "deletedMember"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
byMember: T.GroupMember
|
||||
deletedMember: T.GroupMember
|
||||
withMessages: boolean
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface LeftMember extends Interface {
|
||||
type: "leftMember"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface DeletedMemberUser extends Interface {
|
||||
type: "deletedMemberUser"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
withMessages: boolean
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface GroupDeleted extends Interface {
|
||||
type: "groupDeleted"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface ConnectedToGroupMember extends Interface {
|
||||
type: "connectedToGroupMember"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
memberContact?: T.Contact
|
||||
}
|
||||
|
||||
export interface MemberAcceptedByOther extends Interface {
|
||||
type: "memberAcceptedByOther"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
acceptingMember: T.GroupMember
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface MemberBlockedForAll extends Interface {
|
||||
type: "memberBlockedForAll"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
byMember: T.GroupMember
|
||||
member: T.GroupMember
|
||||
blocked: boolean
|
||||
msgSigned?: T.MsgSigStatus
|
||||
}
|
||||
|
||||
export interface GroupMemberUpdated extends Interface {
|
||||
type: "groupMemberUpdated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
fromMember: T.GroupMember
|
||||
toMember: T.GroupMember
|
||||
}
|
||||
|
||||
export interface GroupLinkDataUpdated extends Interface {
|
||||
type: "groupLinkDataUpdated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupLink: T.GroupLink
|
||||
groupRelays: T.GroupRelay[]
|
||||
relaysChanged: boolean
|
||||
}
|
||||
|
||||
export interface GroupRelayUpdated extends Interface {
|
||||
type: "groupRelayUpdated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
groupRelay: T.GroupRelay
|
||||
}
|
||||
|
||||
export interface RcvFileDescrReady extends Interface {
|
||||
type: "rcvFileDescrReady"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
rcvFileDescr: T.RcvFileDescr
|
||||
}
|
||||
|
||||
export interface RcvFileComplete extends Interface {
|
||||
type: "rcvFileComplete"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface SndFileCompleteXFTP extends Interface {
|
||||
type: "sndFileCompleteXFTP"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
fileTransferMeta: T.FileTransferMeta
|
||||
}
|
||||
|
||||
export interface RcvFileStart extends Interface {
|
||||
type: "rcvFileStart"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface RcvFileSndCancelled extends Interface {
|
||||
type: "rcvFileSndCancelled"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
}
|
||||
|
||||
export interface RcvFileAccepted extends Interface {
|
||||
type: "rcvFileAccepted"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface RcvFileError extends Interface {
|
||||
type: "rcvFileError"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
agentError: T.AgentErrorType
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
}
|
||||
|
||||
export interface RcvFileWarning extends Interface {
|
||||
type: "rcvFileWarning"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
agentError: T.AgentErrorType
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
}
|
||||
|
||||
export interface SndFileError extends Interface {
|
||||
type: "sndFileError"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
fileTransferMeta: T.FileTransferMeta
|
||||
errorMessage: string
|
||||
}
|
||||
|
||||
export interface SndFileWarning extends Interface {
|
||||
type: "sndFileWarning"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
fileTransferMeta: T.FileTransferMeta
|
||||
errorMessage: string
|
||||
}
|
||||
|
||||
export interface AcceptingContactRequest extends Interface {
|
||||
type: "acceptingContactRequest"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface AcceptingBusinessRequest extends Interface {
|
||||
type: "acceptingBusinessRequest"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
}
|
||||
|
||||
export interface ContactConnecting extends Interface {
|
||||
type: "contactConnecting"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface BusinessLinkConnecting extends Interface {
|
||||
type: "businessLinkConnecting"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
hostMember: T.GroupMember
|
||||
fromContact: T.Contact
|
||||
}
|
||||
|
||||
export interface JoinedGroupMemberConnecting extends Interface {
|
||||
type: "joinedGroupMemberConnecting"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
hostMember: T.GroupMember
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface GroupLinkConnecting extends Interface {
|
||||
type: "groupLinkConnecting"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
hostMember: T.GroupMember
|
||||
}
|
||||
|
||||
export interface HostConnected extends Interface {
|
||||
type: "hostConnected"
|
||||
protocol: string
|
||||
transportHost: string
|
||||
}
|
||||
|
||||
export interface HostDisconnected extends Interface {
|
||||
type: "hostDisconnected"
|
||||
protocol: string
|
||||
transportHost: string
|
||||
}
|
||||
|
||||
export interface SubscriptionStatus extends Interface {
|
||||
type: "subscriptionStatus"
|
||||
server: string
|
||||
subscriptionStatus: T.SubscriptionStatus
|
||||
connections: string[]
|
||||
}
|
||||
|
||||
export interface ServiceRequest extends Interface {
|
||||
type: "serviceRequest"
|
||||
user: T.User
|
||||
requestId: string
|
||||
signerKey?: string
|
||||
requestData: object
|
||||
}
|
||||
|
||||
export interface ServiceReplySent extends Interface {
|
||||
type: "serviceReplySent"
|
||||
connectionId: string
|
||||
}
|
||||
|
||||
export interface RemoteCtrlSessionCode extends Interface {
|
||||
type: "remoteCtrlSessionCode"
|
||||
remoteCtrl_?: T.RemoteCtrlInfo
|
||||
sessionCode: string
|
||||
}
|
||||
|
||||
export interface RemoteCtrlStopped extends Interface {
|
||||
type: "remoteCtrlStopped"
|
||||
rcsState: T.RemoteCtrlSessionState
|
||||
rcStopReason: T.RemoteCtrlStopReason
|
||||
}
|
||||
|
||||
export interface MessageError extends Interface {
|
||||
type: "messageError"
|
||||
user: T.User
|
||||
severity: string
|
||||
errorMessage: string
|
||||
}
|
||||
|
||||
export interface ChatError extends Interface {
|
||||
type: "chatError"
|
||||
chatError: T.ChatError
|
||||
}
|
||||
|
||||
export interface ChatErrors extends Interface {
|
||||
type: "chatErrors"
|
||||
chatErrors: T.ChatError[]
|
||||
}
|
||||
}
|
||||
@@ -1,553 +0,0 @@
|
||||
// API Responses
|
||||
// This file is generated automatically.
|
||||
|
||||
import * as T from "./types"
|
||||
|
||||
export type ChatResponse =
|
||||
| CR.AcceptingContactRequest
|
||||
| CR.ActiveUser
|
||||
| CR.ChatItemNotChanged
|
||||
| CR.ChatItemReaction
|
||||
| CR.ChatItemUpdated
|
||||
| CR.ChatItemsDeleted
|
||||
| CR.ChatMsgContent
|
||||
| CR.ChatRunning
|
||||
| CR.ChatStarted
|
||||
| CR.ChatStopped
|
||||
| CR.CmdOk
|
||||
| CR.ChatCmdError
|
||||
| CR.ConnectionPlan
|
||||
| CR.ContactAlreadyExists
|
||||
| CR.ContactConnectionDeleted
|
||||
| CR.ContactDeleted
|
||||
| CR.ContactPrefsUpdated
|
||||
| CR.ContactRequestRejected
|
||||
| CR.ContactsList
|
||||
| CR.GroupDeletedUser
|
||||
| CR.GroupLink
|
||||
| CR.GroupLinkCreated
|
||||
| CR.GroupLinkDeleted
|
||||
| CR.GroupCreated
|
||||
| CR.PublicGroupCreated
|
||||
| CR.PublicGroupCreationFailed
|
||||
| CR.GroupRelays
|
||||
| CR.GroupRelaysAdded
|
||||
| CR.GroupRelaysAddFailed
|
||||
| CR.RelayGroupAllowed
|
||||
| CR.GroupMembers
|
||||
| CR.GroupUpdated
|
||||
| CR.GroupsList
|
||||
| CR.GroupDomainVerified
|
||||
| CR.Invitation
|
||||
| CR.LeftMemberUser
|
||||
| CR.MemberAccepted
|
||||
| CR.MembersBlockedForAllUser
|
||||
| CR.MembersRoleUser
|
||||
| CR.NewChatItems
|
||||
| CR.RcvFileAccepted
|
||||
| CR.RcvFileAcceptedSndCancelled
|
||||
| CR.RcvFileCancelled
|
||||
| CR.RemoteCtrlConnected
|
||||
| CR.RemoteCtrlConnecting
|
||||
| CR.SentConfirmation
|
||||
| CR.SentGroupInvitation
|
||||
| CR.SentInvitation
|
||||
| CR.SentInvitationToContact
|
||||
| CR.ServiceReplyAccepted
|
||||
| CR.SndFileCancelled
|
||||
| CR.StartedConnectionToContact
|
||||
| CR.StartedConnectionToGroup
|
||||
| CR.UserAcceptedGroupSent
|
||||
| CR.UserContactLink
|
||||
| CR.UserContactLinkCreated
|
||||
| CR.UserContactLinkDeleted
|
||||
| CR.UserContactLinkUpdated
|
||||
| CR.UserDeletedMembers
|
||||
| CR.UserProfileUpdated
|
||||
| CR.UserProfileNoChange
|
||||
| CR.UsersList
|
||||
| CR.ApiChats
|
||||
|
||||
export namespace CR {
|
||||
export type Tag =
|
||||
| "acceptingContactRequest"
|
||||
| "activeUser"
|
||||
| "chatItemNotChanged"
|
||||
| "chatItemReaction"
|
||||
| "chatItemUpdated"
|
||||
| "chatItemsDeleted"
|
||||
| "chatMsgContent"
|
||||
| "chatRunning"
|
||||
| "chatStarted"
|
||||
| "chatStopped"
|
||||
| "cmdOk"
|
||||
| "chatCmdError"
|
||||
| "connectionPlan"
|
||||
| "contactAlreadyExists"
|
||||
| "contactConnectionDeleted"
|
||||
| "contactDeleted"
|
||||
| "contactPrefsUpdated"
|
||||
| "contactRequestRejected"
|
||||
| "contactsList"
|
||||
| "groupDeletedUser"
|
||||
| "groupLink"
|
||||
| "groupLinkCreated"
|
||||
| "groupLinkDeleted"
|
||||
| "groupCreated"
|
||||
| "publicGroupCreated"
|
||||
| "publicGroupCreationFailed"
|
||||
| "groupRelays"
|
||||
| "groupRelaysAdded"
|
||||
| "groupRelaysAddFailed"
|
||||
| "relayGroupAllowed"
|
||||
| "groupMembers"
|
||||
| "groupUpdated"
|
||||
| "groupsList"
|
||||
| "groupDomainVerified"
|
||||
| "invitation"
|
||||
| "leftMemberUser"
|
||||
| "memberAccepted"
|
||||
| "membersBlockedForAllUser"
|
||||
| "membersRoleUser"
|
||||
| "newChatItems"
|
||||
| "rcvFileAccepted"
|
||||
| "rcvFileAcceptedSndCancelled"
|
||||
| "rcvFileCancelled"
|
||||
| "remoteCtrlConnected"
|
||||
| "remoteCtrlConnecting"
|
||||
| "sentConfirmation"
|
||||
| "sentGroupInvitation"
|
||||
| "sentInvitation"
|
||||
| "sentInvitationToContact"
|
||||
| "serviceReplyAccepted"
|
||||
| "sndFileCancelled"
|
||||
| "startedConnectionToContact"
|
||||
| "startedConnectionToGroup"
|
||||
| "userAcceptedGroupSent"
|
||||
| "userContactLink"
|
||||
| "userContactLinkCreated"
|
||||
| "userContactLinkDeleted"
|
||||
| "userContactLinkUpdated"
|
||||
| "userDeletedMembers"
|
||||
| "userProfileUpdated"
|
||||
| "userProfileNoChange"
|
||||
| "usersList"
|
||||
| "apiChats"
|
||||
|
||||
interface Interface {
|
||||
type: Tag
|
||||
}
|
||||
|
||||
export interface AcceptingContactRequest extends Interface {
|
||||
type: "acceptingContactRequest"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface ActiveUser extends Interface {
|
||||
type: "activeUser"
|
||||
user: T.User
|
||||
}
|
||||
|
||||
export interface ChatItemNotChanged extends Interface {
|
||||
type: "chatItemNotChanged"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface ChatItemReaction extends Interface {
|
||||
type: "chatItemReaction"
|
||||
user: T.User
|
||||
added: boolean
|
||||
reaction: T.ACIReaction
|
||||
}
|
||||
|
||||
export interface ChatItemUpdated extends Interface {
|
||||
type: "chatItemUpdated"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface ChatItemsDeleted extends Interface {
|
||||
type: "chatItemsDeleted"
|
||||
user: T.User
|
||||
chatItemDeletions: T.ChatItemDeletion[]
|
||||
byUser: boolean
|
||||
timed: boolean
|
||||
}
|
||||
|
||||
export interface ChatMsgContent extends Interface {
|
||||
type: "chatMsgContent"
|
||||
user: T.User
|
||||
msgContent: T.MsgContent
|
||||
}
|
||||
|
||||
export interface ChatRunning extends Interface {
|
||||
type: "chatRunning"
|
||||
}
|
||||
|
||||
export interface ChatStarted extends Interface {
|
||||
type: "chatStarted"
|
||||
}
|
||||
|
||||
export interface ChatStopped extends Interface {
|
||||
type: "chatStopped"
|
||||
}
|
||||
|
||||
export interface CmdOk extends Interface {
|
||||
type: "cmdOk"
|
||||
user_?: T.User
|
||||
}
|
||||
|
||||
export interface ChatCmdError extends Interface {
|
||||
type: "chatCmdError"
|
||||
chatError: T.ChatError
|
||||
}
|
||||
|
||||
export interface ConnectionPlan extends Interface {
|
||||
type: "connectionPlan"
|
||||
user: T.User
|
||||
connLink: T.CreatedConnLink
|
||||
planSimplexName?: T.SimplexNameInfo
|
||||
otherSimplexName?: T.SimplexNameInfo
|
||||
connectionPlan: T.ConnectionPlan
|
||||
}
|
||||
|
||||
export interface ContactAlreadyExists extends Interface {
|
||||
type: "contactAlreadyExists"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface ContactConnectionDeleted extends Interface {
|
||||
type: "contactConnectionDeleted"
|
||||
user: T.User
|
||||
connection: T.PendingContactConnection
|
||||
}
|
||||
|
||||
export interface ContactDeleted extends Interface {
|
||||
type: "contactDeleted"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
}
|
||||
|
||||
export interface ContactPrefsUpdated extends Interface {
|
||||
type: "contactPrefsUpdated"
|
||||
user: T.User
|
||||
fromContact: T.Contact
|
||||
toContact: T.Contact
|
||||
}
|
||||
|
||||
export interface ContactRequestRejected extends Interface {
|
||||
type: "contactRequestRejected"
|
||||
user: T.User
|
||||
contactRequest: T.UserContactRequest
|
||||
contact_?: T.Contact
|
||||
}
|
||||
|
||||
export interface ContactsList extends Interface {
|
||||
type: "contactsList"
|
||||
user: T.User
|
||||
contacts: T.Contact[]
|
||||
}
|
||||
|
||||
export interface GroupDeletedUser extends Interface {
|
||||
type: "groupDeletedUser"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
msgSigned: boolean
|
||||
localDeletion: boolean
|
||||
}
|
||||
|
||||
export interface GroupLink extends Interface {
|
||||
type: "groupLink"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupLink: T.GroupLink
|
||||
}
|
||||
|
||||
export interface GroupLinkCreated extends Interface {
|
||||
type: "groupLinkCreated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupLink: T.GroupLink
|
||||
}
|
||||
|
||||
export interface GroupLinkDeleted extends Interface {
|
||||
type: "groupLinkDeleted"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
}
|
||||
|
||||
export interface GroupCreated extends Interface {
|
||||
type: "groupCreated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
}
|
||||
|
||||
export interface PublicGroupCreated extends Interface {
|
||||
type: "publicGroupCreated"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupLink: T.GroupLink
|
||||
groupRelays: T.GroupRelay[]
|
||||
}
|
||||
|
||||
export interface PublicGroupCreationFailed extends Interface {
|
||||
type: "publicGroupCreationFailed"
|
||||
user: T.User
|
||||
addRelayResults: T.AddRelayResult[]
|
||||
}
|
||||
|
||||
export interface GroupRelays extends Interface {
|
||||
type: "groupRelays"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupRelays: T.GroupRelay[]
|
||||
}
|
||||
|
||||
export interface GroupRelaysAdded extends Interface {
|
||||
type: "groupRelaysAdded"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
groupLink: T.GroupLink
|
||||
groupRelays: T.GroupRelay[]
|
||||
}
|
||||
|
||||
export interface GroupRelaysAddFailed extends Interface {
|
||||
type: "groupRelaysAddFailed"
|
||||
user: T.User
|
||||
addRelayResults: T.AddRelayResult[]
|
||||
}
|
||||
|
||||
export interface RelayGroupAllowed extends Interface {
|
||||
type: "relayGroupAllowed"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
}
|
||||
|
||||
export interface GroupMembers extends Interface {
|
||||
type: "groupMembers"
|
||||
user: T.User
|
||||
group: T.Group
|
||||
}
|
||||
|
||||
export interface GroupUpdated extends Interface {
|
||||
type: "groupUpdated"
|
||||
user: T.User
|
||||
fromGroup: T.GroupInfo
|
||||
toGroup: T.GroupInfo
|
||||
member_?: T.GroupMember
|
||||
msgSigned: boolean
|
||||
}
|
||||
|
||||
export interface GroupsList extends Interface {
|
||||
type: "groupsList"
|
||||
user: T.User
|
||||
groups: T.GroupInfo[]
|
||||
}
|
||||
|
||||
export interface GroupDomainVerified extends Interface {
|
||||
type: "groupDomainVerified"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
verificationFailure?: string
|
||||
}
|
||||
|
||||
export interface Invitation extends Interface {
|
||||
type: "invitation"
|
||||
user: T.User
|
||||
connLinkInvitation: T.CreatedConnLink
|
||||
connection: T.PendingContactConnection
|
||||
}
|
||||
|
||||
export interface LeftMemberUser extends Interface {
|
||||
type: "leftMemberUser"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
}
|
||||
|
||||
export interface MemberAccepted extends Interface {
|
||||
type: "memberAccepted"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface MembersBlockedForAllUser extends Interface {
|
||||
type: "membersBlockedForAllUser"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
members: T.GroupMember[]
|
||||
blocked: boolean
|
||||
msgSigned: boolean
|
||||
}
|
||||
|
||||
export interface MembersRoleUser extends Interface {
|
||||
type: "membersRoleUser"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
members: T.GroupMember[]
|
||||
toRole: T.GroupMemberRole
|
||||
msgSigned: boolean
|
||||
}
|
||||
|
||||
export interface NewChatItems extends Interface {
|
||||
type: "newChatItems"
|
||||
user: T.User
|
||||
chatItems: T.AChatItem[]
|
||||
}
|
||||
|
||||
export interface RcvFileAccepted extends Interface {
|
||||
type: "rcvFileAccepted"
|
||||
user: T.User
|
||||
chatItem: T.AChatItem
|
||||
}
|
||||
|
||||
export interface RcvFileAcceptedSndCancelled extends Interface {
|
||||
type: "rcvFileAcceptedSndCancelled"
|
||||
user: T.User
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
}
|
||||
|
||||
export interface RcvFileCancelled extends Interface {
|
||||
type: "rcvFileCancelled"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
rcvFileTransfer: T.RcvFileTransfer
|
||||
}
|
||||
|
||||
export interface RemoteCtrlConnected extends Interface {
|
||||
type: "remoteCtrlConnected"
|
||||
remoteCtrl: T.RemoteCtrlInfo
|
||||
compression: boolean
|
||||
}
|
||||
|
||||
export interface RemoteCtrlConnecting extends Interface {
|
||||
type: "remoteCtrlConnecting"
|
||||
remoteCtrl_?: T.RemoteCtrlInfo
|
||||
ctrlAppInfo: T.CtrlAppInfo
|
||||
appVersion: string
|
||||
}
|
||||
|
||||
export interface SentConfirmation extends Interface {
|
||||
type: "sentConfirmation"
|
||||
user: T.User
|
||||
connection: T.PendingContactConnection
|
||||
customUserProfile?: T.Profile
|
||||
}
|
||||
|
||||
export interface SentGroupInvitation extends Interface {
|
||||
type: "sentGroupInvitation"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
contact: T.Contact
|
||||
member: T.GroupMember
|
||||
}
|
||||
|
||||
export interface SentInvitation extends Interface {
|
||||
type: "sentInvitation"
|
||||
user: T.User
|
||||
connection: T.PendingContactConnection
|
||||
customUserProfile?: T.Profile
|
||||
}
|
||||
|
||||
export interface SentInvitationToContact extends Interface {
|
||||
type: "sentInvitationToContact"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
customUserProfile?: T.Profile
|
||||
}
|
||||
|
||||
export interface ServiceReplyAccepted extends Interface {
|
||||
type: "serviceReplyAccepted"
|
||||
user: T.User
|
||||
connectionId: string
|
||||
}
|
||||
|
||||
export interface SndFileCancelled extends Interface {
|
||||
type: "sndFileCancelled"
|
||||
user: T.User
|
||||
chatItem_?: T.AChatItem
|
||||
fileTransferMeta: T.FileTransferMeta
|
||||
sndFileTransfers: T.SndFileTransfer[]
|
||||
}
|
||||
|
||||
export interface StartedConnectionToContact extends Interface {
|
||||
type: "startedConnectionToContact"
|
||||
user: T.User
|
||||
contact: T.Contact
|
||||
customUserProfile?: T.Profile
|
||||
}
|
||||
|
||||
export interface StartedConnectionToGroup extends Interface {
|
||||
type: "startedConnectionToGroup"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
customUserProfile?: T.Profile
|
||||
relayResults: T.RelayConnectionResult[]
|
||||
}
|
||||
|
||||
export interface UserAcceptedGroupSent extends Interface {
|
||||
type: "userAcceptedGroupSent"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
hostContact?: T.Contact
|
||||
}
|
||||
|
||||
export interface UserContactLink extends Interface {
|
||||
type: "userContactLink"
|
||||
user: T.User
|
||||
contactLink: T.UserContactLink
|
||||
}
|
||||
|
||||
export interface UserContactLinkCreated extends Interface {
|
||||
type: "userContactLinkCreated"
|
||||
user: T.User
|
||||
connLinkContact: T.CreatedConnLink
|
||||
}
|
||||
|
||||
export interface UserContactLinkDeleted extends Interface {
|
||||
type: "userContactLinkDeleted"
|
||||
user: T.User
|
||||
}
|
||||
|
||||
export interface UserContactLinkUpdated extends Interface {
|
||||
type: "userContactLinkUpdated"
|
||||
user: T.User
|
||||
contactLink: T.UserContactLink
|
||||
}
|
||||
|
||||
export interface UserDeletedMembers extends Interface {
|
||||
type: "userDeletedMembers"
|
||||
user: T.User
|
||||
groupInfo: T.GroupInfo
|
||||
members: T.GroupMember[]
|
||||
withMessages: boolean
|
||||
msgSigned: boolean
|
||||
}
|
||||
|
||||
export interface UserProfileUpdated extends Interface {
|
||||
type: "userProfileUpdated"
|
||||
user: T.User
|
||||
fromProfile: T.Profile
|
||||
toProfile: T.Profile
|
||||
updateSummary: T.UserProfileUpdateSummary
|
||||
}
|
||||
|
||||
export interface UserProfileNoChange extends Interface {
|
||||
type: "userProfileNoChange"
|
||||
user: T.User
|
||||
}
|
||||
|
||||
export interface UsersList extends Interface {
|
||||
type: "usersList"
|
||||
users: T.UserInfo[]
|
||||
}
|
||||
|
||||
export interface ApiChats extends Interface {
|
||||
type: "apiChats"
|
||||
user: T.User
|
||||
chats: T.AChat[]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,825 +0,0 @@
|
||||
# API Commands
|
||||
# This file is generated automatically.
|
||||
from __future__ import annotations
|
||||
import json
|
||||
from typing import NotRequired, TypedDict
|
||||
from . import _types as T
|
||||
from . import _responses as CR
|
||||
|
||||
# Address commands
|
||||
# Bots can use these commands to automatically check and create address when initialized
|
||||
|
||||
# Create bot address.
|
||||
# Network usage: interactive.
|
||||
class APICreateMyAddress(TypedDict):
|
||||
userId: int # int64
|
||||
pqRatchet: NotRequired[bool]
|
||||
|
||||
|
||||
def APICreateMyAddress_cmd_string(self: APICreateMyAddress) -> str:
|
||||
return '/_address ' + str(self['userId']) + ((' pq_ratchet=' + ('on' if self.get('pqRatchet') else 'off')) if self.get('pqRatchet') is not None else '')
|
||||
|
||||
APICreateMyAddress_Response = CR.UserContactLinkCreated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Delete bot address.
|
||||
# Network usage: background.
|
||||
class APIDeleteMyAddress(TypedDict):
|
||||
userId: int # int64
|
||||
|
||||
|
||||
def APIDeleteMyAddress_cmd_string(self: APIDeleteMyAddress) -> str:
|
||||
return '/_delete_address ' + str(self['userId'])
|
||||
|
||||
APIDeleteMyAddress_Response = CR.UserContactLinkDeleted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get bot address and settings.
|
||||
# Network usage: no.
|
||||
class APIShowMyAddress(TypedDict):
|
||||
userId: int # int64
|
||||
|
||||
|
||||
def APIShowMyAddress_cmd_string(self: APIShowMyAddress) -> str:
|
||||
return '/_show_address ' + str(self['userId'])
|
||||
|
||||
APIShowMyAddress_Response = CR.UserContactLink | CR.ChatCmdError
|
||||
|
||||
|
||||
# Add address to bot profile.
|
||||
# Network usage: interactive.
|
||||
class APISetProfileAddress(TypedDict):
|
||||
userId: int # int64
|
||||
enable: bool
|
||||
|
||||
|
||||
def APISetProfileAddress_cmd_string(self: APISetProfileAddress) -> str:
|
||||
return '/_profile_address ' + str(self['userId']) + ' ' + ('on' if self['enable'] else 'off')
|
||||
|
||||
APISetProfileAddress_Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set bot address settings.
|
||||
# Network usage: interactive.
|
||||
class APISetAddressSettings(TypedDict):
|
||||
userId: int # int64
|
||||
pqRatchet: NotRequired[bool]
|
||||
settings: "T.AddressSettings"
|
||||
|
||||
|
||||
def APISetAddressSettings_cmd_string(self: APISetAddressSettings) -> str:
|
||||
return '/_address_settings ' + str(self['userId']) + ((' pq_ratchet=' + ('on' if self.get('pqRatchet') else 'off')) if self.get('pqRatchet') is not None else '') + ' ' + json.dumps(self['settings'])
|
||||
|
||||
APISetAddressSettings_Response = CR.UserContactLinkUpdated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Message commands
|
||||
# Commands to send, update, delete, moderate messages and set message reactions
|
||||
|
||||
# Send messages.
|
||||
# Network usage: background.
|
||||
class APISendMessages(TypedDict):
|
||||
sendRef: "T.ChatRef"
|
||||
liveMessage: bool
|
||||
ttl: NotRequired[int] # int
|
||||
signMessages: bool
|
||||
composedMessages: list["T.ComposedMessage"] # non-empty
|
||||
|
||||
|
||||
def APISendMessages_cmd_string(self: APISendMessages) -> str:
|
||||
return '/_send ' + T.ChatRef_cmd_string(self['sendRef']) + (' live=on' if self['liveMessage'] else '') + ((' ttl=' + str(self.get('ttl'))) if self.get('ttl') is not None else '') + (' sign=on' if self['signMessages'] else '') + ' json ' + json.dumps(self['composedMessages'])
|
||||
|
||||
APISendMessages_Response = CR.NewChatItems | CR.ChatCmdError
|
||||
|
||||
|
||||
# Update message.
|
||||
# Network usage: background.
|
||||
class APIUpdateChatItem(TypedDict):
|
||||
chatRef: "T.ChatRef"
|
||||
chatItemId: int # int64
|
||||
liveMessage: bool
|
||||
updatedMessage: "T.UpdatedMessage"
|
||||
|
||||
|
||||
def APIUpdateChatItem_cmd_string(self: APIUpdateChatItem) -> str:
|
||||
return '/_update item ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + str(self['chatItemId']) + (' live=on' if self['liveMessage'] else '') + ' json ' + json.dumps(self['updatedMessage'])
|
||||
|
||||
APIUpdateChatItem_Response = CR.ChatItemUpdated | CR.ChatItemNotChanged | CR.ChatCmdError
|
||||
|
||||
|
||||
# Delete message.
|
||||
# Network usage: background.
|
||||
class APIDeleteChatItem(TypedDict):
|
||||
chatRef: "T.ChatRef"
|
||||
chatItemIds: list[int] # int64, non-empty
|
||||
deleteMode: "T.CIDeleteMode"
|
||||
|
||||
|
||||
def APIDeleteChatItem_cmd_string(self: APIDeleteChatItem) -> str:
|
||||
return '/_delete item ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + ','.join(map(str, self['chatItemIds'])) + ' ' + str(self['deleteMode'])
|
||||
|
||||
APIDeleteChatItem_Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Moderate message. Requires Moderator role (and higher than message author's).
|
||||
# Network usage: background.
|
||||
class APIDeleteMemberChatItem(TypedDict):
|
||||
groupId: int # int64
|
||||
chatItemIds: list[int] # int64, non-empty
|
||||
|
||||
|
||||
def APIDeleteMemberChatItem_cmd_string(self: APIDeleteMemberChatItem) -> str:
|
||||
return '/_delete member item #' + str(self['groupId']) + ' ' + ','.join(map(str, self['chatItemIds']))
|
||||
|
||||
APIDeleteMemberChatItem_Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Add/remove message reaction.
|
||||
# Network usage: background.
|
||||
class APIChatItemReaction(TypedDict):
|
||||
chatRef: "T.ChatRef"
|
||||
chatItemId: int # int64
|
||||
add: bool
|
||||
reaction: "T.MsgReaction"
|
||||
|
||||
|
||||
def APIChatItemReaction_cmd_string(self: APIChatItemReaction) -> str:
|
||||
return '/_reaction ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + str(self['chatItemId']) + ' ' + ('on' if self['add'] else 'off') + ' ' + json.dumps(self['reaction'])
|
||||
|
||||
APIChatItemReaction_Response = CR.ChatItemReaction | CR.ChatCmdError
|
||||
|
||||
|
||||
# Share user address card
|
||||
# Network usage: no.
|
||||
class APIShareMyAddress(TypedDict):
|
||||
toSendRef: "T.ChatRef"
|
||||
|
||||
|
||||
def APIShareMyAddress_cmd_string(self: APIShareMyAddress) -> str:
|
||||
return '/_share address ' + T.ChatRef_cmd_string(self['toSendRef'])
|
||||
|
||||
APIShareMyAddress_Response = CR.ChatMsgContent
|
||||
|
||||
|
||||
# Share channel address
|
||||
# Network usage: no.
|
||||
class APIShareChatMsgContent(TypedDict):
|
||||
shareChatRef: "T.ChatRef"
|
||||
toSendRef: "T.ChatRef"
|
||||
|
||||
|
||||
def APIShareChatMsgContent_cmd_string(self: APIShareChatMsgContent) -> str:
|
||||
return '/_share chat content ' + T.ChatRef_cmd_string(self['shareChatRef']) + ' ' + T.ChatRef_cmd_string(self['toSendRef'])
|
||||
|
||||
APIShareChatMsgContent_Response = CR.ChatMsgContent
|
||||
|
||||
|
||||
# File commands
|
||||
# Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.
|
||||
|
||||
# Receive file.
|
||||
# Network usage: no.
|
||||
class ReceiveFile(TypedDict):
|
||||
fileId: int # int64
|
||||
userApprovedRelays: bool
|
||||
storeEncrypted: NotRequired[bool]
|
||||
fileInline: NotRequired[bool]
|
||||
filePath: NotRequired[str]
|
||||
|
||||
|
||||
def ReceiveFile_cmd_string(self: ReceiveFile) -> str:
|
||||
return '/freceive ' + str(self['fileId']) + (' approved_relays=on' if self['userApprovedRelays'] else '') + ((' encrypt=' + ('on' if self.get('storeEncrypted') else 'off')) if self.get('storeEncrypted') is not None else '') + ((' inline=' + ('on' if self.get('fileInline') else 'off')) if self.get('fileInline') is not None else '') + ((' ' + self.get('filePath')) if self.get('filePath') is not None else '')
|
||||
|
||||
ReceiveFile_Response = CR.RcvFileAccepted | CR.RcvFileAcceptedSndCancelled | CR.ChatCmdError
|
||||
|
||||
|
||||
# Cancel file.
|
||||
# Network usage: background.
|
||||
class CancelFile(TypedDict):
|
||||
fileId: int # int64
|
||||
|
||||
|
||||
def CancelFile_cmd_string(self: CancelFile) -> str:
|
||||
return '/fcancel ' + str(self['fileId'])
|
||||
|
||||
CancelFile_Response = CR.SndFileCancelled | CR.RcvFileCancelled | CR.ChatCmdError
|
||||
|
||||
|
||||
# Group commands
|
||||
# Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.
|
||||
|
||||
# Add contact to group. Requires bot to have Admin role.
|
||||
# Network usage: interactive.
|
||||
class APIAddMember(TypedDict):
|
||||
groupId: int # int64
|
||||
contactId: int # int64
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APIAddMember_cmd_string(self: APIAddMember) -> str:
|
||||
return '/_add #' + str(self['groupId']) + ' ' + str(self['contactId']) + ' ' + str(self['memberRole'])
|
||||
|
||||
APIAddMember_Response = CR.SentGroupInvitation | CR.ChatCmdError
|
||||
|
||||
|
||||
# Join group.
|
||||
# Network usage: interactive.
|
||||
class APIJoinGroup(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIJoinGroup_cmd_string(self: APIJoinGroup) -> str:
|
||||
return '/_join #' + str(self['groupId'])
|
||||
|
||||
APIJoinGroup_Response = CR.UserAcceptedGroupSent | CR.ChatCmdError
|
||||
|
||||
|
||||
# Accept group member. Requires Admin role.
|
||||
# Network usage: background.
|
||||
class APIAcceptMember(TypedDict):
|
||||
groupId: int # int64
|
||||
groupMemberId: int # int64
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APIAcceptMember_cmd_string(self: APIAcceptMember) -> str:
|
||||
return '/_accept member #' + str(self['groupId']) + ' ' + str(self['groupMemberId']) + ' ' + str(self['memberRole'])
|
||||
|
||||
APIAcceptMember_Response = CR.MemberAccepted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set members role. Requires Admin role.
|
||||
# Network usage: background.
|
||||
class APIMembersRole(TypedDict):
|
||||
groupId: int # int64
|
||||
groupMemberIds: list[int] # int64, non-empty
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APIMembersRole_cmd_string(self: APIMembersRole) -> str:
|
||||
return '/_member role #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + ' ' + str(self['memberRole'])
|
||||
|
||||
APIMembersRole_Response = CR.MembersRoleUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Block members. Requires Moderator role.
|
||||
# Network usage: background.
|
||||
class APIBlockMembersForAll(TypedDict):
|
||||
groupId: int # int64
|
||||
groupMemberIds: list[int] # int64, non-empty
|
||||
blocked: bool
|
||||
|
||||
|
||||
def APIBlockMembersForAll_cmd_string(self: APIBlockMembersForAll) -> str:
|
||||
return '/_block #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + ' blocked=' + ('on' if self['blocked'] else 'off')
|
||||
|
||||
APIBlockMembersForAll_Response = CR.MembersBlockedForAllUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Remove members. Requires Admin role.
|
||||
# Network usage: background.
|
||||
class APIRemoveMembers(TypedDict):
|
||||
groupId: int # int64
|
||||
groupMemberIds: list[int] # int64, non-empty
|
||||
withMessages: bool
|
||||
|
||||
|
||||
def APIRemoveMembers_cmd_string(self: APIRemoveMembers) -> str:
|
||||
return '/_remove #' + str(self['groupId']) + ' ' + ','.join(map(str, self['groupMemberIds'])) + (' messages=on' if self['withMessages'] else '')
|
||||
|
||||
APIRemoveMembers_Response = CR.UserDeletedMembers | CR.ChatCmdError
|
||||
|
||||
|
||||
# Leave group.
|
||||
# Network usage: background.
|
||||
class APILeaveGroup(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APILeaveGroup_cmd_string(self: APILeaveGroup) -> str:
|
||||
return '/_leave #' + str(self['groupId'])
|
||||
|
||||
APILeaveGroup_Response = CR.LeftMemberUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get group members.
|
||||
# Network usage: no.
|
||||
class APIListMembers(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIListMembers_cmd_string(self: APIListMembers) -> str:
|
||||
return '/_members #' + str(self['groupId'])
|
||||
|
||||
APIListMembers_Response = CR.GroupMembers | CR.ChatCmdError
|
||||
|
||||
|
||||
# Create group.
|
||||
# Network usage: no.
|
||||
class APINewGroup(TypedDict):
|
||||
userId: int # int64
|
||||
incognito: bool
|
||||
groupProfile: "T.GroupProfile"
|
||||
|
||||
|
||||
def APINewGroup_cmd_string(self: APINewGroup) -> str:
|
||||
return '/_group ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '') + ' ' + json.dumps(self['groupProfile'])
|
||||
|
||||
APINewGroup_Response = CR.GroupCreated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Create public group.
|
||||
# Network usage: interactive.
|
||||
class APINewPublicGroup(TypedDict):
|
||||
userId: int # int64
|
||||
incognito: bool
|
||||
relayIds: list[int] # int64, non-empty
|
||||
groupProfile: "T.GroupProfile"
|
||||
|
||||
|
||||
def APINewPublicGroup_cmd_string(self: APINewPublicGroup) -> str:
|
||||
return '/_public group ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '') + ' ' + ','.join(map(str, self['relayIds'])) + ' ' + json.dumps(self['groupProfile'])
|
||||
|
||||
APINewPublicGroup_Response = CR.PublicGroupCreated | CR.PublicGroupCreationFailed | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get group relays.
|
||||
# Network usage: no.
|
||||
class APIGetGroupRelays(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIGetGroupRelays_cmd_string(self: APIGetGroupRelays) -> str:
|
||||
return '/_get relays #' + str(self['groupId'])
|
||||
|
||||
APIGetGroupRelays_Response = CR.GroupRelays | CR.ChatCmdError
|
||||
|
||||
|
||||
# Add relays to group.
|
||||
# Network usage: interactive.
|
||||
class APIAddGroupRelays(TypedDict):
|
||||
groupId: int # int64
|
||||
relayIds: list[int] # int64, non-empty
|
||||
|
||||
|
||||
def APIAddGroupRelays_cmd_string(self: APIAddGroupRelays) -> str:
|
||||
return '/_add relays #' + str(self['groupId']) + ' ' + ','.join(map(str, self['relayIds']))
|
||||
|
||||
APIAddGroupRelays_Response = CR.GroupRelaysAdded | CR.GroupRelaysAddFailed | CR.ChatCmdError
|
||||
|
||||
|
||||
# Clear relay rejection for a channel (relay operator).
|
||||
# Network usage: background.
|
||||
class APIAllowRelayGroup(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIAllowRelayGroup_cmd_string(self: APIAllowRelayGroup) -> str:
|
||||
return '/_relay allow #' + str(self['groupId'])
|
||||
|
||||
APIAllowRelayGroup_Response = CR.RelayGroupAllowed | CR.ChatCmdError
|
||||
|
||||
|
||||
# Update group profile.
|
||||
# Network usage: background.
|
||||
class APIUpdateGroupProfile(TypedDict):
|
||||
groupId: int # int64
|
||||
groupProfile: "T.GroupProfile"
|
||||
|
||||
|
||||
def APIUpdateGroupProfile_cmd_string(self: APIUpdateGroupProfile) -> str:
|
||||
return '/_group_profile #' + str(self['groupId']) + ' ' + json.dumps(self['groupProfile'])
|
||||
|
||||
APIUpdateGroupProfile_Response = CR.GroupUpdated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Verify group domain
|
||||
# Network usage: interactive.
|
||||
class APIVerifyGroupDomain(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIVerifyGroupDomain_cmd_string(self: APIVerifyGroupDomain) -> str:
|
||||
return '/_verify domain #' + str(self['groupId'])
|
||||
|
||||
APIVerifyGroupDomain_Response = CR.GroupDomainVerified
|
||||
|
||||
|
||||
# Group link commands
|
||||
# These commands can be used by bots that manage multiple public groups
|
||||
|
||||
# Create group link.
|
||||
# Network usage: interactive.
|
||||
class APICreateGroupLink(TypedDict):
|
||||
groupId: int # int64
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APICreateGroupLink_cmd_string(self: APICreateGroupLink) -> str:
|
||||
return '/_create link #' + str(self['groupId']) + ' ' + str(self['memberRole'])
|
||||
|
||||
APICreateGroupLink_Response = CR.GroupLinkCreated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set member role for group link.
|
||||
# Network usage: no.
|
||||
class APIGroupLinkMemberRole(TypedDict):
|
||||
groupId: int # int64
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APIGroupLinkMemberRole_cmd_string(self: APIGroupLinkMemberRole) -> str:
|
||||
return '/_set link role #' + str(self['groupId']) + ' ' + str(self['memberRole'])
|
||||
|
||||
APIGroupLinkMemberRole_Response = CR.GroupLink | CR.ChatCmdError
|
||||
|
||||
|
||||
# Delete group link.
|
||||
# Network usage: background.
|
||||
class APIDeleteGroupLink(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIDeleteGroupLink_cmd_string(self: APIDeleteGroupLink) -> str:
|
||||
return '/_delete link #' + str(self['groupId'])
|
||||
|
||||
APIDeleteGroupLink_Response = CR.GroupLinkDeleted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get group link.
|
||||
# Network usage: no.
|
||||
class APIGetGroupLink(TypedDict):
|
||||
groupId: int # int64
|
||||
|
||||
|
||||
def APIGetGroupLink_cmd_string(self: APIGetGroupLink) -> str:
|
||||
return '/_get link #' + str(self['groupId'])
|
||||
|
||||
APIGetGroupLink_Response = CR.GroupLink | CR.ChatCmdError
|
||||
|
||||
|
||||
# Connection commands
|
||||
# These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.
|
||||
|
||||
# Create 1-time invitation link.
|
||||
# Network usage: interactive.
|
||||
class APIAddContact(TypedDict):
|
||||
userId: int # int64
|
||||
incognito: bool
|
||||
|
||||
|
||||
def APIAddContact_cmd_string(self: APIAddContact) -> str:
|
||||
return '/_connect ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '')
|
||||
|
||||
APIAddContact_Response = CR.Invitation | CR.ChatCmdError
|
||||
|
||||
|
||||
# Determine SimpleX link type and if the bot is already connected via this link or name.
|
||||
# Network usage: interactive.
|
||||
class APIConnectPlan(TypedDict):
|
||||
userId: int # int64
|
||||
connectTarget: NotRequired[str]
|
||||
resolveMode: "T.PlanResolveMode"
|
||||
linkOwnerSig: NotRequired["T.LinkOwnerSig"]
|
||||
|
||||
|
||||
def APIConnectPlan_cmd_string(self: APIConnectPlan) -> str:
|
||||
return '/_connect plan ' + str(self['userId']) + ' ' + self.get('connectTarget')
|
||||
|
||||
APIConnectPlan_Response = CR.ConnectionPlan | CR.ChatCmdError
|
||||
|
||||
|
||||
# Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link.
|
||||
# Network usage: interactive.
|
||||
class APIConnect(TypedDict):
|
||||
userId: int # int64
|
||||
incognito: bool
|
||||
preparedLink_: NotRequired["T.CreatedConnLink"]
|
||||
|
||||
|
||||
def APIConnect_cmd_string(self: APIConnect) -> str:
|
||||
return '/_connect ' + str(self['userId']) + (' incognito=on' if self['incognito'] else '') + ((' ' + T.CreatedConnLink_cmd_string(self.get('preparedLink_'))) if self.get('preparedLink_') is not None else '')
|
||||
|
||||
APIConnect_Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
||||
|
||||
|
||||
# Connect via SimpleX link or name as string in the active user profile.
|
||||
# Network usage: interactive.
|
||||
class Connect(TypedDict):
|
||||
incognito: bool
|
||||
connTarget_: NotRequired[str]
|
||||
|
||||
|
||||
def Connect_cmd_string(self: Connect) -> str:
|
||||
return '/connect' + ((' ' + self.get('connTarget_')) if self.get('connTarget_') is not None else '')
|
||||
|
||||
Connect_Response = (
|
||||
CR.SentConfirmation
|
||||
| CR.ContactAlreadyExists
|
||||
| CR.SentInvitation
|
||||
| CR.ConnectionPlan
|
||||
| CR.SentInvitationToContact
|
||||
| CR.StartedConnectionToContact
|
||||
| CR.StartedConnectionToGroup
|
||||
| CR.ChatCmdError
|
||||
)
|
||||
|
||||
|
||||
# Accept contact request.
|
||||
# Network usage: interactive.
|
||||
class APIAcceptContact(TypedDict):
|
||||
contactReqId: int # int64
|
||||
|
||||
|
||||
def APIAcceptContact_cmd_string(self: APIAcceptContact) -> str:
|
||||
return '/_accept ' + str(self['contactReqId'])
|
||||
|
||||
APIAcceptContact_Response = CR.AcceptingContactRequest | CR.ChatCmdError
|
||||
|
||||
|
||||
# Reject contact request. The user who sent the request is **not notified**.
|
||||
# Network usage: no.
|
||||
class APIRejectContact(TypedDict):
|
||||
contactReqId: int # int64
|
||||
notify: bool
|
||||
|
||||
|
||||
def APIRejectContact_cmd_string(self: APIRejectContact) -> str:
|
||||
return '/_reject ' + str(self['contactReqId'])
|
||||
|
||||
APIRejectContact_Response = CR.ContactRequestRejected | CR.ChatCmdError
|
||||
|
||||
|
||||
# Chat commands
|
||||
# Commands to list and delete conversations.
|
||||
|
||||
# Get contacts.
|
||||
# Network usage: no.
|
||||
class APIListContacts(TypedDict):
|
||||
userId: int # int64
|
||||
|
||||
|
||||
def APIListContacts_cmd_string(self: APIListContacts) -> str:
|
||||
return '/_contacts ' + str(self['userId'])
|
||||
|
||||
APIListContacts_Response = CR.ContactsList | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get groups.
|
||||
# Network usage: no.
|
||||
class APIListGroups(TypedDict):
|
||||
userId: int # int64
|
||||
contactId_: NotRequired[int] # int64
|
||||
search: NotRequired[str]
|
||||
|
||||
|
||||
def APIListGroups_cmd_string(self: APIListGroups) -> str:
|
||||
return '/_groups ' + str(self['userId']) + ((' @' + str(self.get('contactId_'))) if self.get('contactId_') is not None else '') + ((' ' + self.get('search')) if self.get('search') is not None else '')
|
||||
|
||||
APIListGroups_Response = CR.GroupsList | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get chat previews. Supports time-based pagination — use this instead of APIListContacts / APIListGroups when scanning at scale (those load every record into memory and fail on large databases).
|
||||
# Network usage: no.
|
||||
class APIGetChats(TypedDict):
|
||||
userId: int # int64
|
||||
pendingConnections: bool
|
||||
pagination: NotRequired["T.PaginationByTime"]
|
||||
query: "T.ChatListQuery"
|
||||
|
||||
|
||||
def APIGetChats_cmd_string(self: APIGetChats) -> str:
|
||||
return '/_get chats ' + str(self['userId']) + (' pcc=on' if self['pendingConnections'] else '') + ((' ' + T.PaginationByTime_cmd_string(self.get('pagination'))) if self.get('pagination') is not None else '') + ' ' + json.dumps(self['query'])
|
||||
|
||||
APIGetChats_Response = CR.ApiChats | CR.ChatCmdError
|
||||
|
||||
|
||||
# Delete chat.
|
||||
# Network usage: background.
|
||||
class APIDeleteChat(TypedDict):
|
||||
chatRef: "T.ChatRef"
|
||||
chatDeleteMode: "T.ChatDeleteMode"
|
||||
|
||||
|
||||
def APIDeleteChat_cmd_string(self: APIDeleteChat) -> str:
|
||||
return '/_delete ' + T.ChatRef_cmd_string(self['chatRef']) + ' ' + T.ChatDeleteMode_cmd_string(self['chatDeleteMode'])
|
||||
|
||||
APIDeleteChat_Response = CR.ContactDeleted | CR.ContactConnectionDeleted | CR.GroupDeletedUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set group custom data.
|
||||
# Network usage: no.
|
||||
class APISetGroupCustomData(TypedDict):
|
||||
groupId: int # int64
|
||||
customData: NotRequired[dict[str, object]]
|
||||
|
||||
|
||||
def APISetGroupCustomData_cmd_string(self: APISetGroupCustomData) -> str:
|
||||
return '/_set custom #' + str(self['groupId']) + ((' ' + json.dumps(self.get('customData'))) if self.get('customData') is not None else '')
|
||||
|
||||
APISetGroupCustomData_Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set contact custom data.
|
||||
# Network usage: no.
|
||||
class APISetContactCustomData(TypedDict):
|
||||
contactId: int # int64
|
||||
customData: NotRequired[dict[str, object]]
|
||||
|
||||
|
||||
def APISetContactCustomData_cmd_string(self: APISetContactCustomData) -> str:
|
||||
return '/_set custom @' + str(self['contactId']) + ((' ' + json.dumps(self.get('customData'))) if self.get('customData') is not None else '')
|
||||
|
||||
APISetContactCustomData_Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set auto-accept member contacts.
|
||||
# Network usage: no.
|
||||
class APISetUserAutoAcceptMemberContacts(TypedDict):
|
||||
userId: int # int64
|
||||
onOff: bool
|
||||
|
||||
|
||||
def APISetUserAutoAcceptMemberContacts_cmd_string(self: APISetUserAutoAcceptMemberContacts) -> str:
|
||||
return '/_set accept member contacts ' + str(self['userId']) + ' ' + ('on' if self['onOff'] else 'off')
|
||||
|
||||
APISetUserAutoAcceptMemberContacts_Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set auto-accept group invitations.
|
||||
# Network usage: no.
|
||||
class APISetUserAutoAcceptGroupInvitations(TypedDict):
|
||||
userId: int # int64
|
||||
onOff: bool
|
||||
|
||||
|
||||
def APISetUserAutoAcceptGroupInvitations_cmd_string(self: APISetUserAutoAcceptGroupInvitations) -> str:
|
||||
return '/_set accept group invitations ' + str(self['userId']) + ' ' + ('on' if self['onOff'] else 'off')
|
||||
|
||||
APISetUserAutoAcceptGroupInvitations_Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
|
||||
# User profile commands
|
||||
# Most bots don't need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).
|
||||
|
||||
# Get active user profile.
|
||||
# Network usage: no.
|
||||
class ShowActiveUser(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
def ShowActiveUser_cmd_string(self: ShowActiveUser) -> str:
|
||||
return '/user'
|
||||
|
||||
ShowActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Create new user profile.
|
||||
# Network usage: no.
|
||||
class CreateActiveUser(TypedDict):
|
||||
newUser: "T.NewUser"
|
||||
|
||||
|
||||
def CreateActiveUser_cmd_string(self: CreateActiveUser) -> str:
|
||||
return '/_create user ' + json.dumps(self['newUser'])
|
||||
|
||||
CreateActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Get all user profiles.
|
||||
# Network usage: no.
|
||||
class ListUsers(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
def ListUsers_cmd_string(self: ListUsers) -> str:
|
||||
return '/users'
|
||||
|
||||
ListUsers_Response = CR.UsersList | CR.ChatCmdError
|
||||
|
||||
|
||||
# Set active user profile.
|
||||
# Network usage: no.
|
||||
class APISetActiveUser(TypedDict):
|
||||
userId: int # int64
|
||||
viewPwd: NotRequired[str]
|
||||
|
||||
|
||||
def APISetActiveUser_cmd_string(self: APISetActiveUser) -> str:
|
||||
return '/_user ' + str(self['userId']) + ((' ' + json.dumps(self.get('viewPwd'))) if self.get('viewPwd') is not None else '')
|
||||
|
||||
APISetActiveUser_Response = CR.ActiveUser | CR.ChatCmdError
|
||||
|
||||
|
||||
# Delete user profile.
|
||||
# Network usage: background.
|
||||
class APIDeleteUser(TypedDict):
|
||||
userId: int # int64
|
||||
delSMPQueues: bool
|
||||
viewPwd: NotRequired[str]
|
||||
|
||||
|
||||
def APIDeleteUser_cmd_string(self: APIDeleteUser) -> str:
|
||||
return '/_delete user ' + str(self['userId']) + ' del_smp=' + ('on' if self['delSMPQueues'] else 'off') + ((' ' + json.dumps(self.get('viewPwd'))) if self.get('viewPwd') is not None else '')
|
||||
|
||||
APIDeleteUser_Response = CR.CmdOk | CR.ChatCmdError
|
||||
|
||||
|
||||
# Update user profile.
|
||||
# Network usage: background.
|
||||
class APIUpdateProfile(TypedDict):
|
||||
userId: int # int64
|
||||
profile: "T.Profile"
|
||||
|
||||
|
||||
def APIUpdateProfile_cmd_string(self: APIUpdateProfile) -> str:
|
||||
return '/_profile ' + str(self['userId']) + ' ' + json.dumps(self['profile'])
|
||||
|
||||
APIUpdateProfile_Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
||||
|
||||
|
||||
# Configure chat preference overrides for the contact.
|
||||
# Network usage: background.
|
||||
class APISetContactPrefs(TypedDict):
|
||||
contactId: int # int64
|
||||
preferences: "T.Preferences"
|
||||
|
||||
|
||||
def APISetContactPrefs_cmd_string(self: APISetContactPrefs) -> str:
|
||||
return '/_set prefs @' + str(self['contactId']) + ' ' + json.dumps(self['preferences'])
|
||||
|
||||
APISetContactPrefs_Response = CR.ContactPrefsUpdated | CR.ChatCmdError
|
||||
|
||||
|
||||
# Service commands
|
||||
# Bots with a double ratchet address can answer service requests.
|
||||
|
||||
# Send a reply to a received service request. Returns the connection ID that correlates the reply delivery event.
|
||||
# Network usage: background.
|
||||
class APISendServiceResponse(TypedDict):
|
||||
userId: int # int64
|
||||
requestId: str
|
||||
responseData: dict[str, object]
|
||||
|
||||
|
||||
def APISendServiceResponse_cmd_string(self: APISendServiceResponse) -> str:
|
||||
return '/_service_response ' + str(self['userId']) + ' ' + self['requestId'] + ' ' + json.dumps(self['responseData'])
|
||||
|
||||
APISendServiceResponse_Response = CR.ServiceReplyAccepted | CR.ChatCmdError
|
||||
|
||||
|
||||
# Chat management
|
||||
# These commands should not be used with CLI-based bots
|
||||
|
||||
# Start chat controller.
|
||||
# Network usage: no.
|
||||
class StartChat(TypedDict):
|
||||
mainApp: bool
|
||||
enableSndFiles: bool
|
||||
serviceRequests: bool
|
||||
|
||||
|
||||
def StartChat_cmd_string(self: StartChat) -> str:
|
||||
return '/_start' + ' main=' + ('on' if self['mainApp'] else 'off') + (' snd_files=off' if not self['enableSndFiles'] else '') + (' service_requests=on' if self['serviceRequests'] else '')
|
||||
|
||||
StartChat_Response = CR.ChatStarted | CR.ChatRunning
|
||||
|
||||
|
||||
# Stop chat controller.
|
||||
# Network usage: no.
|
||||
class APIStopChat(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
def APIStopChat_cmd_string(self: APIStopChat) -> str:
|
||||
return '/_stop'
|
||||
|
||||
APIStopChat_Response = CR.ChatStopped
|
||||
|
||||
|
||||
# Remote control commands
|
||||
# Allows a bot to accept an incoming remote control session from a SimpleX Desktop client, giving the desktop live access to the bot's SimpleX instance.
|
||||
|
||||
# Connect to a remote controller using an OOB invitation link.
|
||||
# Network usage: interactive.
|
||||
class ConnectRemoteCtrl(TypedDict):
|
||||
remoteInvitation: str
|
||||
|
||||
|
||||
def ConnectRemoteCtrl_cmd_string(self: ConnectRemoteCtrl) -> str:
|
||||
return '/crc ' + self['remoteInvitation']
|
||||
|
||||
ConnectRemoteCtrl_Response = CR.RemoteCtrlConnecting | CR.ChatCmdError
|
||||
|
||||
|
||||
# Verify the remote controller session code to complete the connection.
|
||||
# Network usage: no.
|
||||
class VerifyRemoteCtrlSession(TypedDict):
|
||||
sessionCode: str
|
||||
|
||||
|
||||
def VerifyRemoteCtrlSession_cmd_string(self: VerifyRemoteCtrlSession) -> str:
|
||||
return '/verify remote ctrl ' + self['sessionCode']
|
||||
|
||||
VerifyRemoteCtrlSession_Response = CR.RemoteCtrlConnected | CR.ChatCmdError
|
||||
|
||||
@@ -1,730 +0,0 @@
|
||||
# API Events
|
||||
# This file is generated automatically.
|
||||
from __future__ import annotations
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Literal, NotRequired, Protocol, TypedDict, overload
|
||||
from . import _types as T
|
||||
|
||||
class ContactConnected(TypedDict):
|
||||
type: Literal["contactConnected"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
userCustomProfile: NotRequired["T.Profile"]
|
||||
|
||||
class ContactUpdated(TypedDict):
|
||||
type: Literal["contactUpdated"]
|
||||
user: "T.User"
|
||||
fromContact: "T.Contact"
|
||||
toContact: "T.Contact"
|
||||
|
||||
class ContactDeletedByContact(TypedDict):
|
||||
type: Literal["contactDeletedByContact"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class ReceivedContactRequest(TypedDict):
|
||||
type: Literal["receivedContactRequest"]
|
||||
user: "T.User"
|
||||
contactRequest: "T.UserContactRequest"
|
||||
chat_: NotRequired["T.AChat"]
|
||||
|
||||
class NewMemberContactReceivedInv(TypedDict):
|
||||
type: Literal["newMemberContactReceivedInv"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class ContactSndReady(TypedDict):
|
||||
type: Literal["contactSndReady"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class NewChatItems(TypedDict):
|
||||
type: Literal["newChatItems"]
|
||||
user: "T.User"
|
||||
chatItems: list["T.AChatItem"]
|
||||
|
||||
class ChatItemReaction(TypedDict):
|
||||
type: Literal["chatItemReaction"]
|
||||
user: "T.User"
|
||||
added: bool
|
||||
reaction: "T.ACIReaction"
|
||||
|
||||
class ChatItemsDeleted(TypedDict):
|
||||
type: Literal["chatItemsDeleted"]
|
||||
user: "T.User"
|
||||
chatItemDeletions: list["T.ChatItemDeletion"]
|
||||
byUser: bool
|
||||
timed: bool
|
||||
|
||||
class ChatItemUpdated(TypedDict):
|
||||
type: Literal["chatItemUpdated"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class GroupChatItemsDeleted(TypedDict):
|
||||
type: Literal["groupChatItemsDeleted"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
chatItemIDs: list[int] # int64
|
||||
byUser: bool
|
||||
member_: NotRequired["T.GroupMember"]
|
||||
|
||||
class ChatItemsStatusesUpdated(TypedDict):
|
||||
type: Literal["chatItemsStatusesUpdated"]
|
||||
user: "T.User"
|
||||
chatItems: list["T.AChatItem"]
|
||||
|
||||
class ReceivedGroupInvitation(TypedDict):
|
||||
type: Literal["receivedGroupInvitation"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
contact: "T.Contact"
|
||||
fromMemberRole: "T.GroupMemberRole"
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
class UserJoinedGroup(TypedDict):
|
||||
type: Literal["userJoinedGroup"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
hostMember: "T.GroupMember"
|
||||
|
||||
class GroupUpdated(TypedDict):
|
||||
type: Literal["groupUpdated"]
|
||||
user: "T.User"
|
||||
fromGroup: "T.GroupInfo"
|
||||
toGroup: "T.GroupInfo"
|
||||
member_: NotRequired["T.GroupMember"]
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class JoinedGroupMember(TypedDict):
|
||||
type: Literal["joinedGroupMember"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class MemberRole(TypedDict):
|
||||
type: Literal["memberRole"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
byMember: "T.GroupMember"
|
||||
member: "T.GroupMember"
|
||||
fromRole: "T.GroupMemberRole"
|
||||
toRole: "T.GroupMemberRole"
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class DeletedMember(TypedDict):
|
||||
type: Literal["deletedMember"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
byMember: "T.GroupMember"
|
||||
deletedMember: "T.GroupMember"
|
||||
withMessages: bool
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class LeftMember(TypedDict):
|
||||
type: Literal["leftMember"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class DeletedMemberUser(TypedDict):
|
||||
type: Literal["deletedMemberUser"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
withMessages: bool
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class GroupDeleted(TypedDict):
|
||||
type: Literal["groupDeleted"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class ConnectedToGroupMember(TypedDict):
|
||||
type: Literal["connectedToGroupMember"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
memberContact: NotRequired["T.Contact"]
|
||||
|
||||
class MemberAcceptedByOther(TypedDict):
|
||||
type: Literal["memberAcceptedByOther"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
acceptingMember: "T.GroupMember"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class MemberBlockedForAll(TypedDict):
|
||||
type: Literal["memberBlockedForAll"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
byMember: "T.GroupMember"
|
||||
member: "T.GroupMember"
|
||||
blocked: bool
|
||||
msgSigned: NotRequired["T.MsgSigStatus"]
|
||||
|
||||
class GroupMemberUpdated(TypedDict):
|
||||
type: Literal["groupMemberUpdated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
fromMember: "T.GroupMember"
|
||||
toMember: "T.GroupMember"
|
||||
|
||||
class GroupLinkDataUpdated(TypedDict):
|
||||
type: Literal["groupLinkDataUpdated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupLink: "T.GroupLink"
|
||||
groupRelays: list["T.GroupRelay"]
|
||||
relaysChanged: bool
|
||||
|
||||
class GroupRelayUpdated(TypedDict):
|
||||
type: Literal["groupRelayUpdated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
groupRelay: "T.GroupRelay"
|
||||
|
||||
class RcvFileDescrReady(TypedDict):
|
||||
type: Literal["rcvFileDescrReady"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
rcvFileDescr: "T.RcvFileDescr"
|
||||
|
||||
class RcvFileComplete(TypedDict):
|
||||
type: Literal["rcvFileComplete"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class SndFileCompleteXFTP(TypedDict):
|
||||
type: Literal["sndFileCompleteXFTP"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
fileTransferMeta: "T.FileTransferMeta"
|
||||
|
||||
class RcvFileStart(TypedDict):
|
||||
type: Literal["rcvFileStart"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class RcvFileSndCancelled(TypedDict):
|
||||
type: Literal["rcvFileSndCancelled"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
|
||||
class RcvFileAccepted(TypedDict):
|
||||
type: Literal["rcvFileAccepted"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class RcvFileError(TypedDict):
|
||||
type: Literal["rcvFileError"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
agentError: "T.AgentErrorType"
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
|
||||
class RcvFileWarning(TypedDict):
|
||||
type: Literal["rcvFileWarning"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
agentError: "T.AgentErrorType"
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
|
||||
class SndFileError(TypedDict):
|
||||
type: Literal["sndFileError"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
fileTransferMeta: "T.FileTransferMeta"
|
||||
errorMessage: str
|
||||
|
||||
class SndFileWarning(TypedDict):
|
||||
type: Literal["sndFileWarning"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
fileTransferMeta: "T.FileTransferMeta"
|
||||
errorMessage: str
|
||||
|
||||
class AcceptingContactRequest(TypedDict):
|
||||
type: Literal["acceptingContactRequest"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class AcceptingBusinessRequest(TypedDict):
|
||||
type: Literal["acceptingBusinessRequest"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
|
||||
class ContactConnecting(TypedDict):
|
||||
type: Literal["contactConnecting"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class BusinessLinkConnecting(TypedDict):
|
||||
type: Literal["businessLinkConnecting"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
hostMember: "T.GroupMember"
|
||||
fromContact: "T.Contact"
|
||||
|
||||
class JoinedGroupMemberConnecting(TypedDict):
|
||||
type: Literal["joinedGroupMemberConnecting"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
hostMember: "T.GroupMember"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class GroupLinkConnecting(TypedDict):
|
||||
type: Literal["groupLinkConnecting"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
hostMember: "T.GroupMember"
|
||||
|
||||
class HostConnected(TypedDict):
|
||||
type: Literal["hostConnected"]
|
||||
protocol: str
|
||||
transportHost: str
|
||||
|
||||
class HostDisconnected(TypedDict):
|
||||
type: Literal["hostDisconnected"]
|
||||
protocol: str
|
||||
transportHost: str
|
||||
|
||||
class SubscriptionStatus(TypedDict):
|
||||
type: Literal["subscriptionStatus"]
|
||||
server: str
|
||||
subscriptionStatus: "T.SubscriptionStatus"
|
||||
connections: list[str]
|
||||
|
||||
class ServiceRequest(TypedDict):
|
||||
type: Literal["serviceRequest"]
|
||||
user: "T.User"
|
||||
requestId: str
|
||||
signerKey: NotRequired[str]
|
||||
requestData: dict[str, object]
|
||||
|
||||
class ServiceReplySent(TypedDict):
|
||||
type: Literal["serviceReplySent"]
|
||||
connectionId: str
|
||||
|
||||
class RemoteCtrlSessionCode(TypedDict):
|
||||
type: Literal["remoteCtrlSessionCode"]
|
||||
remoteCtrl_: NotRequired["T.RemoteCtrlInfo"]
|
||||
sessionCode: str
|
||||
|
||||
class RemoteCtrlStopped(TypedDict):
|
||||
type: Literal["remoteCtrlStopped"]
|
||||
rcsState: "T.RemoteCtrlSessionState"
|
||||
rcStopReason: "T.RemoteCtrlStopReason"
|
||||
|
||||
class MessageError(TypedDict):
|
||||
type: Literal["messageError"]
|
||||
user: "T.User"
|
||||
severity: str
|
||||
errorMessage: str
|
||||
|
||||
class ChatError(TypedDict):
|
||||
type: Literal["chatError"]
|
||||
chatError: "T.ChatError"
|
||||
|
||||
class ChatErrors(TypedDict):
|
||||
type: Literal["chatErrors"]
|
||||
chatErrors: list["T.ChatError"]
|
||||
|
||||
ChatEvent = (
|
||||
ContactConnected
|
||||
| ContactUpdated
|
||||
| ContactDeletedByContact
|
||||
| ReceivedContactRequest
|
||||
| NewMemberContactReceivedInv
|
||||
| ContactSndReady
|
||||
| NewChatItems
|
||||
| ChatItemReaction
|
||||
| ChatItemsDeleted
|
||||
| ChatItemUpdated
|
||||
| GroupChatItemsDeleted
|
||||
| ChatItemsStatusesUpdated
|
||||
| ReceivedGroupInvitation
|
||||
| UserJoinedGroup
|
||||
| GroupUpdated
|
||||
| JoinedGroupMember
|
||||
| MemberRole
|
||||
| DeletedMember
|
||||
| LeftMember
|
||||
| DeletedMemberUser
|
||||
| GroupDeleted
|
||||
| ConnectedToGroupMember
|
||||
| MemberAcceptedByOther
|
||||
| MemberBlockedForAll
|
||||
| GroupMemberUpdated
|
||||
| GroupLinkDataUpdated
|
||||
| GroupRelayUpdated
|
||||
| RcvFileDescrReady
|
||||
| RcvFileComplete
|
||||
| SndFileCompleteXFTP
|
||||
| RcvFileStart
|
||||
| RcvFileSndCancelled
|
||||
| RcvFileAccepted
|
||||
| RcvFileError
|
||||
| RcvFileWarning
|
||||
| SndFileError
|
||||
| SndFileWarning
|
||||
| AcceptingContactRequest
|
||||
| AcceptingBusinessRequest
|
||||
| ContactConnecting
|
||||
| BusinessLinkConnecting
|
||||
| JoinedGroupMemberConnecting
|
||||
| GroupLinkConnecting
|
||||
| HostConnected
|
||||
| HostDisconnected
|
||||
| SubscriptionStatus
|
||||
| ServiceRequest
|
||||
| ServiceReplySent
|
||||
| RemoteCtrlSessionCode
|
||||
| RemoteCtrlStopped
|
||||
| MessageError
|
||||
| ChatError
|
||||
| ChatErrors
|
||||
)
|
||||
|
||||
ChatEvent_Tag = Literal["contactConnected", "contactUpdated", "contactDeletedByContact", "receivedContactRequest", "newMemberContactReceivedInv", "contactSndReady", "newChatItems", "chatItemReaction", "chatItemsDeleted", "chatItemUpdated", "groupChatItemsDeleted", "chatItemsStatusesUpdated", "receivedGroupInvitation", "userJoinedGroup", "groupUpdated", "joinedGroupMember", "memberRole", "deletedMember", "leftMember", "deletedMemberUser", "groupDeleted", "connectedToGroupMember", "memberAcceptedByOther", "memberBlockedForAll", "groupMemberUpdated", "groupLinkDataUpdated", "groupRelayUpdated", "rcvFileDescrReady", "rcvFileComplete", "sndFileCompleteXFTP", "rcvFileStart", "rcvFileSndCancelled", "rcvFileAccepted", "rcvFileError", "rcvFileWarning", "sndFileError", "sndFileWarning", "acceptingContactRequest", "acceptingBusinessRequest", "contactConnecting", "businessLinkConnecting", "joinedGroupMemberConnecting", "groupLinkConnecting", "hostConnected", "hostDisconnected", "subscriptionStatus", "serviceRequest", "serviceReplySent", "remoteCtrlSessionCode", "remoteCtrlStopped", "messageError", "chatError", "chatErrors"]
|
||||
|
||||
|
||||
class OnEventDecorator(Protocol):
|
||||
"""Per-tag narrowing protocol for ``Client.on_event``.
|
||||
|
||||
``@client.on_event("contactConnected")`` types the handler's
|
||||
``evt`` parameter as :class:`ContactConnected` rather than the
|
||||
unnarrowed :data:`ChatEvent` union.
|
||||
"""
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["contactConnected"], /) -> Callable[
|
||||
[Callable[["ContactConnected"], Awaitable[None]]],
|
||||
Callable[["ContactConnected"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["contactUpdated"], /) -> Callable[
|
||||
[Callable[["ContactUpdated"], Awaitable[None]]],
|
||||
Callable[["ContactUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["contactDeletedByContact"], /) -> Callable[
|
||||
[Callable[["ContactDeletedByContact"], Awaitable[None]]],
|
||||
Callable[["ContactDeletedByContact"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["receivedContactRequest"], /) -> Callable[
|
||||
[Callable[["ReceivedContactRequest"], Awaitable[None]]],
|
||||
Callable[["ReceivedContactRequest"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["newMemberContactReceivedInv"], /) -> Callable[
|
||||
[Callable[["NewMemberContactReceivedInv"], Awaitable[None]]],
|
||||
Callable[["NewMemberContactReceivedInv"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["contactSndReady"], /) -> Callable[
|
||||
[Callable[["ContactSndReady"], Awaitable[None]]],
|
||||
Callable[["ContactSndReady"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["newChatItems"], /) -> Callable[
|
||||
[Callable[["NewChatItems"], Awaitable[None]]],
|
||||
Callable[["NewChatItems"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatItemReaction"], /) -> Callable[
|
||||
[Callable[["ChatItemReaction"], Awaitable[None]]],
|
||||
Callable[["ChatItemReaction"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatItemsDeleted"], /) -> Callable[
|
||||
[Callable[["ChatItemsDeleted"], Awaitable[None]]],
|
||||
Callable[["ChatItemsDeleted"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatItemUpdated"], /) -> Callable[
|
||||
[Callable[["ChatItemUpdated"], Awaitable[None]]],
|
||||
Callable[["ChatItemUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupChatItemsDeleted"], /) -> Callable[
|
||||
[Callable[["GroupChatItemsDeleted"], Awaitable[None]]],
|
||||
Callable[["GroupChatItemsDeleted"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatItemsStatusesUpdated"], /) -> Callable[
|
||||
[Callable[["ChatItemsStatusesUpdated"], Awaitable[None]]],
|
||||
Callable[["ChatItemsStatusesUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["receivedGroupInvitation"], /) -> Callable[
|
||||
[Callable[["ReceivedGroupInvitation"], Awaitable[None]]],
|
||||
Callable[["ReceivedGroupInvitation"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["userJoinedGroup"], /) -> Callable[
|
||||
[Callable[["UserJoinedGroup"], Awaitable[None]]],
|
||||
Callable[["UserJoinedGroup"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupUpdated"], /) -> Callable[
|
||||
[Callable[["GroupUpdated"], Awaitable[None]]],
|
||||
Callable[["GroupUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["joinedGroupMember"], /) -> Callable[
|
||||
[Callable[["JoinedGroupMember"], Awaitable[None]]],
|
||||
Callable[["JoinedGroupMember"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["memberRole"], /) -> Callable[
|
||||
[Callable[["MemberRole"], Awaitable[None]]],
|
||||
Callable[["MemberRole"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["deletedMember"], /) -> Callable[
|
||||
[Callable[["DeletedMember"], Awaitable[None]]],
|
||||
Callable[["DeletedMember"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["leftMember"], /) -> Callable[
|
||||
[Callable[["LeftMember"], Awaitable[None]]],
|
||||
Callable[["LeftMember"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["deletedMemberUser"], /) -> Callable[
|
||||
[Callable[["DeletedMemberUser"], Awaitable[None]]],
|
||||
Callable[["DeletedMemberUser"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupDeleted"], /) -> Callable[
|
||||
[Callable[["GroupDeleted"], Awaitable[None]]],
|
||||
Callable[["GroupDeleted"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["connectedToGroupMember"], /) -> Callable[
|
||||
[Callable[["ConnectedToGroupMember"], Awaitable[None]]],
|
||||
Callable[["ConnectedToGroupMember"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["memberAcceptedByOther"], /) -> Callable[
|
||||
[Callable[["MemberAcceptedByOther"], Awaitable[None]]],
|
||||
Callable[["MemberAcceptedByOther"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["memberBlockedForAll"], /) -> Callable[
|
||||
[Callable[["MemberBlockedForAll"], Awaitable[None]]],
|
||||
Callable[["MemberBlockedForAll"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupMemberUpdated"], /) -> Callable[
|
||||
[Callable[["GroupMemberUpdated"], Awaitable[None]]],
|
||||
Callable[["GroupMemberUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupLinkDataUpdated"], /) -> Callable[
|
||||
[Callable[["GroupLinkDataUpdated"], Awaitable[None]]],
|
||||
Callable[["GroupLinkDataUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupRelayUpdated"], /) -> Callable[
|
||||
[Callable[["GroupRelayUpdated"], Awaitable[None]]],
|
||||
Callable[["GroupRelayUpdated"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileDescrReady"], /) -> Callable[
|
||||
[Callable[["RcvFileDescrReady"], Awaitable[None]]],
|
||||
Callable[["RcvFileDescrReady"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileComplete"], /) -> Callable[
|
||||
[Callable[["RcvFileComplete"], Awaitable[None]]],
|
||||
Callable[["RcvFileComplete"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["sndFileCompleteXFTP"], /) -> Callable[
|
||||
[Callable[["SndFileCompleteXFTP"], Awaitable[None]]],
|
||||
Callable[["SndFileCompleteXFTP"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileStart"], /) -> Callable[
|
||||
[Callable[["RcvFileStart"], Awaitable[None]]],
|
||||
Callable[["RcvFileStart"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileSndCancelled"], /) -> Callable[
|
||||
[Callable[["RcvFileSndCancelled"], Awaitable[None]]],
|
||||
Callable[["RcvFileSndCancelled"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileAccepted"], /) -> Callable[
|
||||
[Callable[["RcvFileAccepted"], Awaitable[None]]],
|
||||
Callable[["RcvFileAccepted"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileError"], /) -> Callable[
|
||||
[Callable[["RcvFileError"], Awaitable[None]]],
|
||||
Callable[["RcvFileError"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["rcvFileWarning"], /) -> Callable[
|
||||
[Callable[["RcvFileWarning"], Awaitable[None]]],
|
||||
Callable[["RcvFileWarning"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["sndFileError"], /) -> Callable[
|
||||
[Callable[["SndFileError"], Awaitable[None]]],
|
||||
Callable[["SndFileError"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["sndFileWarning"], /) -> Callable[
|
||||
[Callable[["SndFileWarning"], Awaitable[None]]],
|
||||
Callable[["SndFileWarning"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["acceptingContactRequest"], /) -> Callable[
|
||||
[Callable[["AcceptingContactRequest"], Awaitable[None]]],
|
||||
Callable[["AcceptingContactRequest"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["acceptingBusinessRequest"], /) -> Callable[
|
||||
[Callable[["AcceptingBusinessRequest"], Awaitable[None]]],
|
||||
Callable[["AcceptingBusinessRequest"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["contactConnecting"], /) -> Callable[
|
||||
[Callable[["ContactConnecting"], Awaitable[None]]],
|
||||
Callable[["ContactConnecting"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["businessLinkConnecting"], /) -> Callable[
|
||||
[Callable[["BusinessLinkConnecting"], Awaitable[None]]],
|
||||
Callable[["BusinessLinkConnecting"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["joinedGroupMemberConnecting"], /) -> Callable[
|
||||
[Callable[["JoinedGroupMemberConnecting"], Awaitable[None]]],
|
||||
Callable[["JoinedGroupMemberConnecting"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["groupLinkConnecting"], /) -> Callable[
|
||||
[Callable[["GroupLinkConnecting"], Awaitable[None]]],
|
||||
Callable[["GroupLinkConnecting"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["hostConnected"], /) -> Callable[
|
||||
[Callable[["HostConnected"], Awaitable[None]]],
|
||||
Callable[["HostConnected"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["hostDisconnected"], /) -> Callable[
|
||||
[Callable[["HostDisconnected"], Awaitable[None]]],
|
||||
Callable[["HostDisconnected"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["subscriptionStatus"], /) -> Callable[
|
||||
[Callable[["SubscriptionStatus"], Awaitable[None]]],
|
||||
Callable[["SubscriptionStatus"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["serviceRequest"], /) -> Callable[
|
||||
[Callable[["ServiceRequest"], Awaitable[None]]],
|
||||
Callable[["ServiceRequest"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["serviceReplySent"], /) -> Callable[
|
||||
[Callable[["ServiceReplySent"], Awaitable[None]]],
|
||||
Callable[["ServiceReplySent"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["remoteCtrlSessionCode"], /) -> Callable[
|
||||
[Callable[["RemoteCtrlSessionCode"], Awaitable[None]]],
|
||||
Callable[["RemoteCtrlSessionCode"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["remoteCtrlStopped"], /) -> Callable[
|
||||
[Callable[["RemoteCtrlStopped"], Awaitable[None]]],
|
||||
Callable[["RemoteCtrlStopped"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["messageError"], /) -> Callable[
|
||||
[Callable[["MessageError"], Awaitable[None]]],
|
||||
Callable[["MessageError"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatError"], /) -> Callable[
|
||||
[Callable[["ChatError"], Awaitable[None]]],
|
||||
Callable[["ChatError"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["chatErrors"], /) -> Callable[
|
||||
[Callable[["ChatErrors"], Awaitable[None]]],
|
||||
Callable[["ChatErrors"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: str, /) -> Callable[
|
||||
[Callable[["ChatEvent"], Awaitable[None]]],
|
||||
Callable[["ChatEvent"], Awaitable[None]],
|
||||
]: ...
|
||||
@@ -1,423 +0,0 @@
|
||||
# API Responses
|
||||
# This file is generated automatically.
|
||||
from __future__ import annotations
|
||||
from typing import Literal, NotRequired, TypedDict
|
||||
from . import _types as T
|
||||
|
||||
class AcceptingContactRequest(TypedDict):
|
||||
type: Literal["acceptingContactRequest"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class ActiveUser(TypedDict):
|
||||
type: Literal["activeUser"]
|
||||
user: "T.User"
|
||||
|
||||
class ChatItemNotChanged(TypedDict):
|
||||
type: Literal["chatItemNotChanged"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class ChatItemReaction(TypedDict):
|
||||
type: Literal["chatItemReaction"]
|
||||
user: "T.User"
|
||||
added: bool
|
||||
reaction: "T.ACIReaction"
|
||||
|
||||
class ChatItemUpdated(TypedDict):
|
||||
type: Literal["chatItemUpdated"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class ChatItemsDeleted(TypedDict):
|
||||
type: Literal["chatItemsDeleted"]
|
||||
user: "T.User"
|
||||
chatItemDeletions: list["T.ChatItemDeletion"]
|
||||
byUser: bool
|
||||
timed: bool
|
||||
|
||||
class ChatMsgContent(TypedDict):
|
||||
type: Literal["chatMsgContent"]
|
||||
user: "T.User"
|
||||
msgContent: "T.MsgContent"
|
||||
|
||||
class ChatRunning(TypedDict):
|
||||
type: Literal["chatRunning"]
|
||||
|
||||
class ChatStarted(TypedDict):
|
||||
type: Literal["chatStarted"]
|
||||
|
||||
class ChatStopped(TypedDict):
|
||||
type: Literal["chatStopped"]
|
||||
|
||||
class CmdOk(TypedDict):
|
||||
type: Literal["cmdOk"]
|
||||
user_: NotRequired["T.User"]
|
||||
|
||||
class ChatCmdError(TypedDict):
|
||||
type: Literal["chatCmdError"]
|
||||
chatError: "T.ChatError"
|
||||
|
||||
class ConnectionPlan(TypedDict):
|
||||
type: Literal["connectionPlan"]
|
||||
user: "T.User"
|
||||
connLink: "T.CreatedConnLink"
|
||||
planSimplexName: NotRequired["T.SimplexNameInfo"]
|
||||
otherSimplexName: NotRequired["T.SimplexNameInfo"]
|
||||
connectionPlan: "T.ConnectionPlan"
|
||||
|
||||
class ContactAlreadyExists(TypedDict):
|
||||
type: Literal["contactAlreadyExists"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class ContactConnectionDeleted(TypedDict):
|
||||
type: Literal["contactConnectionDeleted"]
|
||||
user: "T.User"
|
||||
connection: "T.PendingContactConnection"
|
||||
|
||||
class ContactDeleted(TypedDict):
|
||||
type: Literal["contactDeleted"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
|
||||
class ContactPrefsUpdated(TypedDict):
|
||||
type: Literal["contactPrefsUpdated"]
|
||||
user: "T.User"
|
||||
fromContact: "T.Contact"
|
||||
toContact: "T.Contact"
|
||||
|
||||
class ContactRequestRejected(TypedDict):
|
||||
type: Literal["contactRequestRejected"]
|
||||
user: "T.User"
|
||||
contactRequest: "T.UserContactRequest"
|
||||
contact_: NotRequired["T.Contact"]
|
||||
|
||||
class ContactsList(TypedDict):
|
||||
type: Literal["contactsList"]
|
||||
user: "T.User"
|
||||
contacts: list["T.Contact"]
|
||||
|
||||
class GroupDeletedUser(TypedDict):
|
||||
type: Literal["groupDeletedUser"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
msgSigned: bool
|
||||
localDeletion: bool
|
||||
|
||||
class GroupLink(TypedDict):
|
||||
type: Literal["groupLink"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupLink: "T.GroupLink"
|
||||
|
||||
class GroupLinkCreated(TypedDict):
|
||||
type: Literal["groupLinkCreated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupLink: "T.GroupLink"
|
||||
|
||||
class GroupLinkDeleted(TypedDict):
|
||||
type: Literal["groupLinkDeleted"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
|
||||
class GroupCreated(TypedDict):
|
||||
type: Literal["groupCreated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
|
||||
class PublicGroupCreated(TypedDict):
|
||||
type: Literal["publicGroupCreated"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupLink: "T.GroupLink"
|
||||
groupRelays: list["T.GroupRelay"]
|
||||
|
||||
class PublicGroupCreationFailed(TypedDict):
|
||||
type: Literal["publicGroupCreationFailed"]
|
||||
user: "T.User"
|
||||
addRelayResults: list["T.AddRelayResult"]
|
||||
|
||||
class GroupRelays(TypedDict):
|
||||
type: Literal["groupRelays"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupRelays: list["T.GroupRelay"]
|
||||
|
||||
class GroupRelaysAdded(TypedDict):
|
||||
type: Literal["groupRelaysAdded"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
groupLink: "T.GroupLink"
|
||||
groupRelays: list["T.GroupRelay"]
|
||||
|
||||
class GroupRelaysAddFailed(TypedDict):
|
||||
type: Literal["groupRelaysAddFailed"]
|
||||
user: "T.User"
|
||||
addRelayResults: list["T.AddRelayResult"]
|
||||
|
||||
class RelayGroupAllowed(TypedDict):
|
||||
type: Literal["relayGroupAllowed"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
|
||||
class GroupMembers(TypedDict):
|
||||
type: Literal["groupMembers"]
|
||||
user: "T.User"
|
||||
group: "T.Group"
|
||||
|
||||
class GroupUpdated(TypedDict):
|
||||
type: Literal["groupUpdated"]
|
||||
user: "T.User"
|
||||
fromGroup: "T.GroupInfo"
|
||||
toGroup: "T.GroupInfo"
|
||||
member_: NotRequired["T.GroupMember"]
|
||||
msgSigned: bool
|
||||
|
||||
class GroupsList(TypedDict):
|
||||
type: Literal["groupsList"]
|
||||
user: "T.User"
|
||||
groups: list["T.GroupInfo"]
|
||||
|
||||
class GroupDomainVerified(TypedDict):
|
||||
type: Literal["groupDomainVerified"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
verificationFailure: NotRequired[str]
|
||||
|
||||
class Invitation(TypedDict):
|
||||
type: Literal["invitation"]
|
||||
user: "T.User"
|
||||
connLinkInvitation: "T.CreatedConnLink"
|
||||
connection: "T.PendingContactConnection"
|
||||
|
||||
class LeftMemberUser(TypedDict):
|
||||
type: Literal["leftMemberUser"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
|
||||
class MemberAccepted(TypedDict):
|
||||
type: Literal["memberAccepted"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class MembersBlockedForAllUser(TypedDict):
|
||||
type: Literal["membersBlockedForAllUser"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
members: list["T.GroupMember"]
|
||||
blocked: bool
|
||||
msgSigned: bool
|
||||
|
||||
class MembersRoleUser(TypedDict):
|
||||
type: Literal["membersRoleUser"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
members: list["T.GroupMember"]
|
||||
toRole: "T.GroupMemberRole"
|
||||
msgSigned: bool
|
||||
|
||||
class NewChatItems(TypedDict):
|
||||
type: Literal["newChatItems"]
|
||||
user: "T.User"
|
||||
chatItems: list["T.AChatItem"]
|
||||
|
||||
class RcvFileAccepted(TypedDict):
|
||||
type: Literal["rcvFileAccepted"]
|
||||
user: "T.User"
|
||||
chatItem: "T.AChatItem"
|
||||
|
||||
class RcvFileAcceptedSndCancelled(TypedDict):
|
||||
type: Literal["rcvFileAcceptedSndCancelled"]
|
||||
user: "T.User"
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
|
||||
class RcvFileCancelled(TypedDict):
|
||||
type: Literal["rcvFileCancelled"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
rcvFileTransfer: "T.RcvFileTransfer"
|
||||
|
||||
class RemoteCtrlConnected(TypedDict):
|
||||
type: Literal["remoteCtrlConnected"]
|
||||
remoteCtrl: "T.RemoteCtrlInfo"
|
||||
compression: bool
|
||||
|
||||
class RemoteCtrlConnecting(TypedDict):
|
||||
type: Literal["remoteCtrlConnecting"]
|
||||
remoteCtrl_: NotRequired["T.RemoteCtrlInfo"]
|
||||
ctrlAppInfo: "T.CtrlAppInfo"
|
||||
appVersion: str
|
||||
|
||||
class SentConfirmation(TypedDict):
|
||||
type: Literal["sentConfirmation"]
|
||||
user: "T.User"
|
||||
connection: "T.PendingContactConnection"
|
||||
customUserProfile: NotRequired["T.Profile"]
|
||||
|
||||
class SentGroupInvitation(TypedDict):
|
||||
type: Literal["sentGroupInvitation"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
contact: "T.Contact"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class SentInvitation(TypedDict):
|
||||
type: Literal["sentInvitation"]
|
||||
user: "T.User"
|
||||
connection: "T.PendingContactConnection"
|
||||
customUserProfile: NotRequired["T.Profile"]
|
||||
|
||||
class SentInvitationToContact(TypedDict):
|
||||
type: Literal["sentInvitationToContact"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
customUserProfile: NotRequired["T.Profile"]
|
||||
|
||||
class ServiceReplyAccepted(TypedDict):
|
||||
type: Literal["serviceReplyAccepted"]
|
||||
user: "T.User"
|
||||
connectionId: str
|
||||
|
||||
class SndFileCancelled(TypedDict):
|
||||
type: Literal["sndFileCancelled"]
|
||||
user: "T.User"
|
||||
chatItem_: NotRequired["T.AChatItem"]
|
||||
fileTransferMeta: "T.FileTransferMeta"
|
||||
sndFileTransfers: list["T.SndFileTransfer"]
|
||||
|
||||
class StartedConnectionToContact(TypedDict):
|
||||
type: Literal["startedConnectionToContact"]
|
||||
user: "T.User"
|
||||
contact: "T.Contact"
|
||||
customUserProfile: NotRequired["T.Profile"]
|
||||
|
||||
class StartedConnectionToGroup(TypedDict):
|
||||
type: Literal["startedConnectionToGroup"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
customUserProfile: NotRequired["T.Profile"]
|
||||
relayResults: list["T.RelayConnectionResult"]
|
||||
|
||||
class UserAcceptedGroupSent(TypedDict):
|
||||
type: Literal["userAcceptedGroupSent"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
hostContact: NotRequired["T.Contact"]
|
||||
|
||||
class UserContactLink(TypedDict):
|
||||
type: Literal["userContactLink"]
|
||||
user: "T.User"
|
||||
contactLink: "T.UserContactLink"
|
||||
|
||||
class UserContactLinkCreated(TypedDict):
|
||||
type: Literal["userContactLinkCreated"]
|
||||
user: "T.User"
|
||||
connLinkContact: "T.CreatedConnLink"
|
||||
|
||||
class UserContactLinkDeleted(TypedDict):
|
||||
type: Literal["userContactLinkDeleted"]
|
||||
user: "T.User"
|
||||
|
||||
class UserContactLinkUpdated(TypedDict):
|
||||
type: Literal["userContactLinkUpdated"]
|
||||
user: "T.User"
|
||||
contactLink: "T.UserContactLink"
|
||||
|
||||
class UserDeletedMembers(TypedDict):
|
||||
type: Literal["userDeletedMembers"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
members: list["T.GroupMember"]
|
||||
withMessages: bool
|
||||
msgSigned: bool
|
||||
|
||||
class UserProfileUpdated(TypedDict):
|
||||
type: Literal["userProfileUpdated"]
|
||||
user: "T.User"
|
||||
fromProfile: "T.Profile"
|
||||
toProfile: "T.Profile"
|
||||
updateSummary: "T.UserProfileUpdateSummary"
|
||||
|
||||
class UserProfileNoChange(TypedDict):
|
||||
type: Literal["userProfileNoChange"]
|
||||
user: "T.User"
|
||||
|
||||
class UsersList(TypedDict):
|
||||
type: Literal["usersList"]
|
||||
users: list["T.UserInfo"]
|
||||
|
||||
class ApiChats(TypedDict):
|
||||
type: Literal["apiChats"]
|
||||
user: "T.User"
|
||||
chats: list["T.AChat"]
|
||||
|
||||
ChatResponse = (
|
||||
AcceptingContactRequest
|
||||
| ActiveUser
|
||||
| ChatItemNotChanged
|
||||
| ChatItemReaction
|
||||
| ChatItemUpdated
|
||||
| ChatItemsDeleted
|
||||
| ChatMsgContent
|
||||
| ChatRunning
|
||||
| ChatStarted
|
||||
| ChatStopped
|
||||
| CmdOk
|
||||
| ChatCmdError
|
||||
| ConnectionPlan
|
||||
| ContactAlreadyExists
|
||||
| ContactConnectionDeleted
|
||||
| ContactDeleted
|
||||
| ContactPrefsUpdated
|
||||
| ContactRequestRejected
|
||||
| ContactsList
|
||||
| GroupDeletedUser
|
||||
| GroupLink
|
||||
| GroupLinkCreated
|
||||
| GroupLinkDeleted
|
||||
| GroupCreated
|
||||
| PublicGroupCreated
|
||||
| PublicGroupCreationFailed
|
||||
| GroupRelays
|
||||
| GroupRelaysAdded
|
||||
| GroupRelaysAddFailed
|
||||
| RelayGroupAllowed
|
||||
| GroupMembers
|
||||
| GroupUpdated
|
||||
| GroupsList
|
||||
| GroupDomainVerified
|
||||
| Invitation
|
||||
| LeftMemberUser
|
||||
| MemberAccepted
|
||||
| MembersBlockedForAllUser
|
||||
| MembersRoleUser
|
||||
| NewChatItems
|
||||
| RcvFileAccepted
|
||||
| RcvFileAcceptedSndCancelled
|
||||
| RcvFileCancelled
|
||||
| RemoteCtrlConnected
|
||||
| RemoteCtrlConnecting
|
||||
| SentConfirmation
|
||||
| SentGroupInvitation
|
||||
| SentInvitation
|
||||
| SentInvitationToContact
|
||||
| ServiceReplyAccepted
|
||||
| SndFileCancelled
|
||||
| StartedConnectionToContact
|
||||
| StartedConnectionToGroup
|
||||
| UserAcceptedGroupSent
|
||||
| UserContactLink
|
||||
| UserContactLinkCreated
|
||||
| UserContactLinkDeleted
|
||||
| UserContactLinkUpdated
|
||||
| UserDeletedMembers
|
||||
| UserProfileUpdated
|
||||
| UserProfileNoChange
|
||||
| UsersList
|
||||
| ApiChats
|
||||
)
|
||||
|
||||
ChatResponse_Tag = Literal["acceptingContactRequest", "activeUser", "chatItemNotChanged", "chatItemReaction", "chatItemUpdated", "chatItemsDeleted", "chatMsgContent", "chatRunning", "chatStarted", "chatStopped", "cmdOk", "chatCmdError", "connectionPlan", "contactAlreadyExists", "contactConnectionDeleted", "contactDeleted", "contactPrefsUpdated", "contactRequestRejected", "contactsList", "groupDeletedUser", "groupLink", "groupLinkCreated", "groupLinkDeleted", "groupCreated", "publicGroupCreated", "publicGroupCreationFailed", "groupRelays", "groupRelaysAdded", "groupRelaysAddFailed", "relayGroupAllowed", "groupMembers", "groupUpdated", "groupsList", "groupDomainVerified", "invitation", "leftMemberUser", "memberAccepted", "membersBlockedForAllUser", "membersRoleUser", "newChatItems", "rcvFileAccepted", "rcvFileAcceptedSndCancelled", "rcvFileCancelled", "remoteCtrlConnected", "remoteCtrlConnecting", "sentConfirmation", "sentGroupInvitation", "sentInvitation", "sentInvitationToContact", "serviceReplyAccepted", "sndFileCancelled", "startedConnectionToContact", "startedConnectionToGroup", "userAcceptedGroupSent", "userContactLink", "userContactLinkCreated", "userContactLinkDeleted", "userContactLinkUpdated", "userDeletedMembers", "userProfileUpdated", "userProfileNoChange", "usersList", "apiChats"]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2,7 +2,7 @@
|
||||
|
||||
Defines the core half of #7525 (`ab/names-lookup-api`). Model: `plans/sketches/2026-09-18-names-lookup-flows.excalidraw`, states 1a–4d. Sibling canvas `plans/sketches/2026-09-18-names-phase3a-registration.excalidraw` on `ab/names-actions-api` (#7530), §5. Registry types from simplexmq `ea43df2349f6d3dedd60d5e4aed21fd99316cad9`, `src/Simplex/Messaging/Names/Record.hs`.
|
||||
|
||||
No UI work here. This is the contract the Kotlin and Swift apps code against, and nothing in it depends on the wallet (#7475) or on either name-actions API.
|
||||
The only UI work here is removing the name cache both apps kept (§9). This is the contract the Kotlin and Swift apps code against, and nothing in it depends on the wallet (#7475) or on either name-actions API.
|
||||
|
||||
---
|
||||
|
||||
@@ -16,8 +16,9 @@ No UI work here. This is the contract the Kotlin and Swift apps code against, an
|
||||
6. What stays an error
|
||||
7. Decisions taken
|
||||
8. Compile fixes and regeneration
|
||||
9. Order of work
|
||||
10. Done means
|
||||
9. Re-resolution in core
|
||||
10. Order of work
|
||||
11. Done means
|
||||
|
||||
---
|
||||
|
||||
@@ -43,9 +44,9 @@ None of it is reachable:
|
||||
- **`connLink :: Maybe` has no producer** — `Commands.hs:2178` and `:4586` still pass a bare `ACreatedConnLink`.
|
||||
- **It does not compile.** `View.hs:2234` and `:2252` pattern-match `CPContactAddress cap` / `CPGroupLink glp` at the old arity, `viewConnectionPlan` (`View.hs:2214`) takes a non-`Maybe` link and has no `CPNameNotConnectable` case, and `Commands.hs:2178`/`:4586` type-error on the response field.
|
||||
|
||||
**Scope.** Core only: types, producer, CLI rendering, generated client types, tests. No Kotlin, no Swift, no migration, no new chat command.
|
||||
**Scope.** Core: types, producer, CLI rendering, generated client types, tests, and one migration per backend (§9); in the apps, only removing the name cache. No new chat command.
|
||||
|
||||
**Not in scope, deliberately.** Registration, renewal and pricing actions — those are #7530 and are reached from the UI, not from a connection plan (§7). No name-resolution cache or TTL in core: the once-a-day rule is expressible with the modes that already exist (§5).
|
||||
**Not in scope, deliberately.** Registration, renewal and pricing actions — those are #7530 and are reached from the UI, not from a connection plan (§7).
|
||||
|
||||
---
|
||||
|
||||
@@ -80,9 +81,9 @@ connectPlan :: User -> AConnectTarget -> PlanResolveMode -> Maybe LinkOwnerSig
|
||||
|
||||
The fifth parameter is `NameRecord` today (`Commands.hs:4392`); widening it to `NameRegistration` is what lets the recursion carry expiry, pricing and reserved-reason down to the plan that is finally built. `resolveNameLink` (`:4568-4574`) pattern-matches `NRRegistered {nameRecord}` and throws `SDENoValidLink` otherwise, as it effectively does now.
|
||||
|
||||
**`PRMAll` gets its meaning.** It is the contact-side counterpart of `PRMAllGroups`: re-resolve a name whose chat is already known, instead of short-circuiting in `knownLinkPlans`. `PRMAllGroups` covers only groups (`Commands.hs:4509`); contacts have had no escape at all.
|
||||
**`PRMAll` gets its meaning, and replaces `PRMAllGroups`.** It re-resolves a chat that is already known, instead of short-circuiting in `knownLinkPlans`. `PRMAllGroups` did this for groups only, so it is removed and the directory service uses `PRMAll`.
|
||||
|
||||
Nothing is removed. `SimplexDomainError` keeps both constructors (§6).
|
||||
Nothing else is removed. `SimplexDomainError` keeps both constructors (§6).
|
||||
|
||||
---
|
||||
|
||||
@@ -113,9 +114,9 @@ Step 4 is the whole of 2b–2f, 3d, 4c and 4d, and it is why `connLink` had to b
|
||||
|
||||
**Expiry is a producer rule, not a UI rule.** An expired name must not yield a connectable plan — "It does not connect while only its owner can renew it". `expires` absent (a v20/v21 router sent the record alone) means expiry is unknown, so the name is treated as live — the only safe reading. The dateless fallback in §4 covers the other case: `expires` known and past, `graceUntil` absent.
|
||||
|
||||
**`addressChanged`.** Under `PRMAll`, when the target is a `CTName` and `knownLinkPlans` returns a known contact or group, resolve the link anyway and compare it with the stored one. Equal, or `PRMUnknown`: today's `CAPKnown` / `GLPKnown`, which is 3a. Different: return the `Ok` plan **for the new link**, with `addressChanged = True` — the canvas draws 3c as a profile card for the new address with *Open new chat*, not as a known chat. Every other construction site passes `False`.
|
||||
**`addressChanged`.** Under `PRMAll`, or under `PRMUnknown` when the stored resolution is stale (§9), when the target is a `CTName` and `knownLinkPlans` returns a known contact or group, resolve the link anyway and compare it with the stored one. Equal, or fresh under `PRMUnknown`: today's `CAPKnown` / `GLPKnown`, which is 3a. Different: return the `Ok` plan **for the new link**, with `addressChanged = True` — the canvas draws 3c as a profile card for the new address with *Open new chat*, not as a known chat. Every other construction site passes `False`.
|
||||
|
||||
**Attach on every name target.** `nameRegistration_` is `Just` whenever the connect target was a name, `Nothing` for a link target, regardless of state — so 2a and 3a carry it too and the UI simply ignores it. One rule beats nine.
|
||||
**Attach on every name target.** `nameRegistration_` is `Just` whenever the connect target was a name, `Nothing` for a link target, regardless of state — so 2a and 3a carry it too and the UI simply ignores it. One rule beats nine. The exception is a known chat answered from the store (§9): the registry is not asked, so it is `Nothing`.
|
||||
|
||||
---
|
||||
|
||||
@@ -133,7 +134,7 @@ Step 4 is the whole of 2b–2f, 3d, 4c and 4d, and it is why `connLink` had to b
|
||||
| 2f | `NRRegistered`, live, no usable link | none | `CPNameNotConnectable d nr` | `Nothing` |
|
||||
| 2g | link resolved, its profile claims another name or none | — | `CPError (… SDEUnknownDomain)` | unchanged |
|
||||
| 2h | network or protocol failure | — | `CPError` | unchanged |
|
||||
| 3a | any | known chat | `CPContactAddress (CAPKnown ct) (Just nr)` / `CPGroupLink (GLPKnown …) (Just nr)` | `Just` stored |
|
||||
| 3a | any, or not asked when fresh (§9) | known chat | `CPContactAddress (CAPKnown ct) (Just nr)` / `CPGroupLink (GLPKnown …) (Just nr)`, with `Nothing` when not asked | `Just` stored |
|
||||
| 3b | `NRRegistered`, `expires` past | known chat | `CPContactAddress (CAPKnown ct) (Just nr)` | `Just` stored |
|
||||
| 3c | `NRRegistered`, live, link ≠ stored | known chat | `CPContactAddress (CAPOk … True) (Just nr)` | `Just` resolved |
|
||||
| 3d | `NRAvailable` or `NRReserved` | known chat | `CPContactAddress (CAPKnown ct) (Just nr)` | `Just` stored |
|
||||
@@ -155,16 +156,17 @@ Four readings are left to the UI, because core cannot make them without guessing
|
||||
|
||||
## 5. Resolve modes, and the once-a-day rule
|
||||
|
||||
The canvas asks that a name you have a chat for resolve at most once a day, or when past its expiry, and that any other name resolve on every tap. No new mode and no core state is needed, because a bare name is already resolved on every call except `PRMNever` (`Commands.hs:4415-4418`), and `PRMNever` already means *use my chat if I have one, otherwise tell me nothing*:
|
||||
The canvas asks that a name you have a chat for resolve at most once a day, or when past its expiry, and that any other name resolve on every tap. Core applies this under the default mode, from state it stores beside the verification flags (§9):
|
||||
|
||||
| caller state | mode | result |
|
||||
|---|---|---|
|
||||
| known chat, answer fresh | `PRMNever` | `CAPKnown` from the store, no network — 3a |
|
||||
| known chat, stale or past expiry | `PRMAll` | registry + link resolve + compare — 3b, 3c, 3d |
|
||||
| no known chat | `PRMAll` | full resolution — band 2 |
|
||||
| known chat, resolved within a day and not past expiry | `PRMUnknown` | `CAPKnown` from the store, no network — 3a |
|
||||
| known chat, stale or past expiry | `PRMUnknown` | registry + link resolve + compare — 3b, 3c, 3d |
|
||||
| no known chat | `PRMUnknown` | full resolution — band 2 |
|
||||
| forced refresh (directory service) | `PRMAll` | always resolves |
|
||||
| per keystroke in search | `PRMNever` | local hit, or `CENotResolvedLocally` swallowed |
|
||||
|
||||
Core therefore stays stateless and needs no change for the rule at all. **Where the client keeps the freshness timestamp is left to the UI plan** — it is not a core decision, and the modes above serve it either way. `PRMUnknown` keeps today's meaning and stays the default for link targets and for every other caller; nothing existing changes behaviour.
|
||||
Link targets keep today's `PRMUnknown` meaning: a known chat is answered from the store.
|
||||
|
||||
`CENotResolvedLocally` continues to be returned for a `PRMNever` miss and continues to be swallowed by both apps.
|
||||
|
||||
@@ -187,7 +189,7 @@ Registry and network failures stay `CPError` (2h). The canvas shows the resolver
|
||||
3. **Dateless alerts rather than suppressed ones.** A user on an old router still learns the name expired; only the two dates go.
|
||||
4. **Registration does not go through `ConnectionPlan`.** On the sibling canvas, 5a and 5b are the only registration states that would need one — 5a is `CPContactAddress (CAPKnown ct) (Just NRRegistered)`, 5b is `CPContactAddress (CAPOk …) (Just NRRegistered)` — and both are proposed for dropping (`b898b991d`, "suggest to drop 5a & 5b"). With them gone the registration check is a plain name-status call, this API keeps one consumer, and the two surfaces stop competing. Nothing here becomes removable as a result: every field 5a and 5b would have used is independently required by 3b and 3d.
|
||||
5. **Consequently the lookup canvas's footer line "registration will always resolve" is obsolete** and should come off the sketch with this change.
|
||||
6. **No cache in core.** §5 shows the rule is expressible with existing modes; a TTL column would be a migration bought for nothing.
|
||||
6. **Reversed on review (2026-09-24): the freshness rule is in core, not the UIs.** Kept in the apps it was duplicated, lost on export, and keyed by domain name alone, so it was shared across user profiles and, under remote access, across hosts. §9.
|
||||
7. **The constructor is `CPNameNotConnectable`, renamed from `CPSimplexName`.** All five states it carries share one invariant — you cannot connect — and the attached `NameRegistration` says why. Rejected, with reasons, so they are not re-litigated: *`CPUnregisteredSimplexName`* is false for 2b and 2f, which are registered; *`CPNonResolvingName`* is false for 2b, where both `resolveNameRecord` and `resolveNameLink` succeed and the refusal is policy, and it collides with `CENotResolvedLocally` and with 2h, the cases that genuinely do not resolve; *`CPSimplexName`* reads as a sibling of `CPContactAddress` / `CPGroupLink` naming the target kind, but a name that resolves produces those instead. `CPSimplexDomain`, asked for in review on `ea721d33f`, is vague rather than wrong and remains the fallback if the thread is reopened. The ordering follows the file's dominant negation pattern — `<Noun>Not<Predicate>`, 20 constructors including the close sibling `CESimplexDomainNotReady`; a `Non` prefix appears nowhere in `src/`.
|
||||
|
||||
---
|
||||
@@ -200,7 +202,29 @@ Registry and network failures stay `CPError` (2h). The canvas shows the resolver
|
||||
- `CAPOk` / `GLPOk` construction sites take `addressChanged`.
|
||||
- Regenerate the client types: `bots/api/TYPES.md:1903-1922`, `packages/simplex-chat-client/types/typescript/src/types.ts`, `packages/simplex-chat-python/src/simplex_chat/types/_types.py` all still describe the three-constructor plan. Note that `bots/src/API/Docs/Commands.hs:142` and both generated clients never emit `resolve=`, which is fine and stays.
|
||||
|
||||
**Encoding note for the app work that follows.** `ConnectionPlan` derives through `sumTypeJSON`, which is `_owsf`-tagged on iOS and `type`-tagged elsewhere, but `NameRegistration` derives through `taggedObjectJSON` unconditionally — deliberately, since it is the RNAME payload. So one iOS response mixes both forms: `{"_owsf":"contactAddress","contactAddress":{…,"nameRegistration_":{"type":"registered",…}}}`. The Swift decoder for `NameRegistration` must be written for the `type` form. Its `reservedReason` is a bare string that may hold anything up to 32 characters (`NRRUnknown`), so both clients need a default branch.
|
||||
**Encoding note for the app work that follows.** `ConnectionPlan` derives through `sumTypeJSON`, which is `_owsf`-tagged on iOS and `type`-tagged elsewhere, but `NameRegistration` derives through `taggedObjectJSON` unconditionally — deliberately, since it is the RNAME payload. So one iOS response mixes both forms: `{"_owsf":"contactAddress","contactAddress":{…,"nameRegistration_":{"type":"registered",…}}}`. The Swift decoder for `NameRegistration` is therefore hand-written for the `type` form, as `MsgChatLink`'s is (#6821) — a protocol type in the same position — and follows it: `private enum CodingKeys`, `forKey: .type`, a `container` binding, and an `"Unknown … type"` error. simplexmq cannot switch to `sumTypeJSON`: that is platform-conditional in the core too, so an iOS build would expect `_owsf` while the relay forwards the resolver's `type` form. Its `reservedReason` is a bare string that may hold anything up to 32 characters (`NRRUnknown`), so both clients need a default branch.
|
||||
|
||||
---
|
||||
|
||||
## 9. Re-resolution in core
|
||||
|
||||
Review on 2026-09-24 reversed decision 6. Each decision below was taken by the author, not the implementer.
|
||||
|
||||
1. **Storage.** `contact_profiles.contact_domain_resolved_at` and `contact_domain_expires_at`; `groups.group_domain_resolved_at` and `group_domain_expires_at` — beside `contact_domain_verified` and `group_domain_verified`, which record whether the name checked out; these record when it was last resolved and when its registration expires. `TEXT` in SQLite, `TIMESTAMPTZ` in Postgres, `_at` as in `badge_purchases.expires_at`. One migration per backend.
|
||||
2. **Rule.** Under `PRMUnknown`, a known chat reached by a name is re-resolved when `resolved_at` is `NULL` or over a day old, or `expires_at` has passed. `PRMAll` always resolves; `PRMNever` never does. A name with no chat is resolved on every call and nothing is stored; the user's own address is not a chat, so it too is resolved on every call.
|
||||
3. **Writes.** Wherever core sets a verification flag after a resolution, it also sets `resolved_at` to now and `expires_at` to the registration's expiry, or `NULL` when the caller does not have it — then only the one-day limit applies until the next resolution. That is `setContactDomainVerified`, `setGroupDomainVerified`, and `createPreparedContact`, which inserts a chat created by name already verified. To supply the expiry, `resolveNameRecord` returns it beside the record, for `/_verify domain` (both kinds) and `APISetPublicGroupAccess` to pass on, and `updateGroupFromLinkData` takes it from its callers, since it must not resolve. One path gains a write: a re-resolution confirming the name still resolves to the known chat, which writes nothing today. It re-sets the flag to `True`, a no-op, since only verified chats are found by name.
|
||||
4. **Moved name.** When re-resolution finds the name resolves elsewhere (3c), nothing is written to the old chat. It stays stale, so each default lookup re-resolves and reports the new address; `resolve=never` still returns the old chat.
|
||||
5. **Reading.** A store function reads the two columns for the one chat being planned. `LocalProfile` and `GroupInfo` do not change, so the columns never reach the UIs; loading them there would touch 19 queries in 6 store files and both types' JSON.
|
||||
6. **UIs.** Both apps lose the cache — the preference, `SimplexNameResolved`, the local probe before resolving, and the invalidation in `UserAddressView` — and plan a name with the default mode.
|
||||
7. **iOS decoding.** Unchanged in substance, per §8.
|
||||
|
||||
**Tests**, in core. A name re-pointed with `registerName` shows whether core queried the registry; a stored time is backdated with `withCCTransaction … DB.execute "UPDATE …"`, as `tests/ChatTests/Groups.hs:8825` does:
|
||||
- a fresh known chat is answered from the store: after re-pointing, the default plan still returns the old contact;
|
||||
- with `resolved_at` backdated, the default plan re-resolves and reports the new address;
|
||||
- with `expires_at` in the past, likewise;
|
||||
- a name with no chat resolves on every call and stores nothing;
|
||||
- a moved name stays stale: two default lookups both report the new address;
|
||||
- `resolve=all` and `resolve=never` are unchanged, and existing tests using them stay as they are.
|
||||
|
||||
---
|
||||
|
||||
@@ -216,6 +240,8 @@ Registry and network failures stay `CPError` (2h). The canvas shows the resolver
|
||||
|
||||
**E. Regeneration.** §8. Done when the generated types describe five constructors.
|
||||
|
||||
**F. Re-resolution in core.** §9: the migration and store functions, the rule and its writes, the core tests, then removing the cache from both apps and aligning the Swift decoder with `MsgChatLink` (§8). Done when the §9 tests and the full names suite pass and neither app keeps a name cache.
|
||||
|
||||
---
|
||||
|
||||
## Done means
|
||||
@@ -223,9 +249,9 @@ Registry and network failures stay `CPError` (2h). The canvas shows the resolver
|
||||
- `tests/NameResolver.hs` can answer expired, reserved and available, not only registered-without-dates
|
||||
- every row of §4 is produced by core and asserted by a test
|
||||
- `CPNameNotConnectable` carries a domain and is returned only when no local chat claims the name
|
||||
- `nameRegistration_` is `Just` for every name target and `Nothing` for every link target
|
||||
- `PRMAll` re-resolves a known contact, `PRMAllGroups` is unchanged, `PRMNever` is unchanged
|
||||
- `nameRegistration_` is `Just` for every name target the registry was asked about, and `Nothing` for every link target and every known chat answered from the store
|
||||
- `PRMAll` re-resolves a known chat, `PRMAllGroups` is removed, `PRMNever` is unchanged, and `PRMUnknown` applies the rule in §9
|
||||
- an expired name never yields a connectable plan, and an absent `expires` is treated as live
|
||||
- `resolve=all` on a known chat whose name moved returns an `Ok` plan with `addressChanged = True`
|
||||
- `cabal build` and `cabal test` are clean, and the generated client types match
|
||||
- no migration, no new chat command, no UI file touched
|
||||
- one migration per backend, no new chat command, and no name cache left in either app
|
||||
@@ -167,6 +167,7 @@ library
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260904_file_badges
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260915_user_badges
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260918_badge_issue_errors
|
||||
Simplex.Chat.Store.Postgres.Migrations.M20260924_simplex_name_resolved
|
||||
else
|
||||
exposed-modules:
|
||||
Simplex.Chat.Archive
|
||||
@@ -343,6 +344,7 @@ library
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260904_file_badges
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260915_user_badges
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260918_badge_issue_errors
|
||||
Simplex.Chat.Store.SQLite.Migrations.M20260924_simplex_name_resolved
|
||||
other-modules:
|
||||
Paths_simplex_chat
|
||||
hs-source-dirs:
|
||||
|
||||
@@ -123,7 +123,7 @@ import Simplex.Messaging.Parsers (base64P)
|
||||
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType (..), ErrorType (NAME), MsgFlags (..), NameRecord (..), NameRegistration (..), NameResponse (..), NtfServer, ProtoServerWithAuth (..), ProtocolServer, ProtocolType (..), ProtocolTypeI (..), SProtocolType (..), SubscriptionMode (..), UserProtocol, userProtocol)
|
||||
import qualified Simplex.Messaging.Protocol as SMP
|
||||
import Simplex.Messaging.ServiceScheme (ServiceScheme (..))
|
||||
import Simplex.Messaging.SystemTime (getSystemSeconds)
|
||||
import Simplex.Messaging.SystemTime (getSystemSeconds, roundedToUTCTime)
|
||||
import qualified Simplex.Messaging.TMap as TM
|
||||
import Simplex.Messaging.Transport.Client (defaultSocksProxyWithAuth)
|
||||
import Simplex.Messaging.Util
|
||||
@@ -1605,7 +1605,7 @@ processChatCommand cxt nm = \case
|
||||
UserContactLink {shortLinkDataSet, connLinkContact = CCLink _ sl_} <- withFastStore (`getUserAddress` user)
|
||||
case sl_ of
|
||||
Just sl | shortLinkDataSet -> do
|
||||
NameRecord {nrSimplexContact} <- resolveNameRecord user nm domain
|
||||
(NameRecord {nrSimplexContact}, _) <- resolveNameRecord user nm domain
|
||||
unless (nameResolvesTo sl nrSimplexContact) $ throwChatError $ CESimplexDomainNotReady domain SDENoValidLink
|
||||
pure $ Just (CLShort sl)
|
||||
_ -> throwCmdError "create the address short link and add it to name"
|
||||
@@ -1958,7 +1958,7 @@ processChatCommand cxt nm = \case
|
||||
(_, cData@(ContactLinkData _ UserContactData {relays = currentRelayLinks}), _) <- getShortLinkConnReq' nm user sLnk
|
||||
groupSLinkData_ <- liftIO $ decodeLinkUserData cData
|
||||
gInfo' <- case groupSLinkData_ of
|
||||
Just sLinkData -> fst <$> updateGroupFromLinkData user gInfo sLinkData Nothing
|
||||
Just sLinkData -> fst <$> updateGroupFromLinkData user gInfo sLinkData Nothing Nothing
|
||||
_ -> pure gInfo
|
||||
when (memberRole' (membership gInfo) /= GROwner && memberCurrent (membership gInfo)) $
|
||||
withGroupLock "syncSubscriberRelays" groupId $
|
||||
@@ -2410,21 +2410,21 @@ processChatCommand cxt nm = \case
|
||||
let connLink_ = preparedContact >>= \PreparedContact {connLinkToConnect = ACCL m (CCLink _ sLnk_)} -> ACSL m <$> sLnk_
|
||||
domain <- maybe (throwCmdError "contact has no name to verify") pure contactDomain
|
||||
(verified, reason) <- verifyEntityDomain user nm NTContact domain connLink_
|
||||
ct' <- maybe (pure ct) (\v -> withFastStore' $ \db -> setContactDomainVerified db user ct v) verified
|
||||
ct' <- maybe (pure ct) (\(v, expiresAt) -> withFastStore' $ \db -> setContactDomainVerified db user ct v expiresAt) verified
|
||||
pure $ CRContactDomainVerified user ct' reason
|
||||
APIVerifyGroupDomain groupId -> withUser $ \user -> do
|
||||
g@GroupInfo {groupProfile = GroupProfile {publicGroup}} <- withFastStore $ \db -> getGroupInfo db cxt user groupId
|
||||
PublicGroupProfile {groupLink, publicGroupAccess} <- maybe (throwCmdError "not a public group") pure publicGroup
|
||||
claim <- maybe (throwCmdError "group has no name to verify") pure $ publicGroupAccess >>= groupDomainClaim
|
||||
-- checks the profile link, not the link we joined through (which may have rotated)
|
||||
(verified, reason) <-
|
||||
(verified, reason, expiresAt) <-
|
||||
tryAllErrors (resolveNameRecord user nm (claimDomain claim)) >>= \case
|
||||
Right NameRecord {nrSimplexChannel}
|
||||
| nameResolvesTo groupLink nrSimplexChannel -> pure (True, Nothing)
|
||||
| otherwise -> pure (False, Just "the name does not resolve to the link in the group profile")
|
||||
Left (ChatErrorAgent {agentError = SMP _ (NAME SMP.NOT_FOUND)}) -> pure (False, Just "the name is not registered")
|
||||
Right (NameRecord {nrSimplexChannel}, expiresAt)
|
||||
| nameResolvesTo groupLink nrSimplexChannel -> pure (True, Nothing, expiresAt)
|
||||
| otherwise -> pure (False, Just "the name does not resolve to the link in the group profile", expiresAt)
|
||||
Left (ChatErrorAgent {agentError = SMP _ (NAME SMP.NOT_FOUND)}) -> pure (False, Just "the name is not registered", Nothing)
|
||||
Left e -> throwError e
|
||||
g' <- withFastStore' $ \db -> setGroupDomainVerified db user g verified
|
||||
g' <- withFastStore' $ \db -> setGroupDomainVerified db user g verified expiresAt
|
||||
pure $ CRGroupDomainVerified user g' reason
|
||||
APIConnectContactViaAddress userId incognito contactId -> withUserId userId $ \user -> do
|
||||
ct@Contact {profile = LocalProfile {contactLink}} <- withFastStore $ \db -> getContact db cxt user contactId
|
||||
@@ -3278,7 +3278,7 @@ processChatCommand cxt nm = \case
|
||||
processChatCommand cxt nm $ APIListGroups userId (contactId' <$> ct_) search_
|
||||
APIUpdateGroupProfile groupId p' -> withUser $ \user -> do
|
||||
gInfo <- withFastStore $ \db -> getGroupInfoKeys db cxt user groupId
|
||||
runUpdateGroupProfile user gInfo p' False
|
||||
runUpdateGroupProfile user gInfo p' Nothing
|
||||
UpdateGroupNames gName GroupProfile {displayName, fullName, shortDescr} ->
|
||||
updateGroupProfileByName gName $ \p -> p {displayName, fullName, shortDescr}
|
||||
ShowGroupProfile gName -> withUser $ \user ->
|
||||
@@ -3292,11 +3292,11 @@ processChatCommand cxt nm = \case
|
||||
case publicGroup of
|
||||
Just pg@PublicGroupProfile {groupLink, publicGroupAccess = existingAccess} -> do
|
||||
let domainChanged = (claimDomain <$> newClaim) /= (claimDomain <$> (existingAccess >>= groupDomainClaim))
|
||||
forM_ (claimDomain <$> newClaim) $ \newDomain ->
|
||||
when domainChanged $ do
|
||||
NameRecord {nrSimplexChannel} <- resolveNameRecord user nm newDomain
|
||||
unless (nameResolvesTo groupLink nrSimplexChannel) $ throwChatError $ CESimplexDomainNotReady newDomain SDENoValidLink
|
||||
runUpdateGroupProfile user gInfo p {publicGroup = Just pg {publicGroupAccess = Just access}} (isJust newClaim && domainChanged)
|
||||
verifiedExpiry_ <- forM (if domainChanged then claimDomain <$> newClaim else Nothing) $ \newDomain -> do
|
||||
(NameRecord {nrSimplexChannel}, expiresAt) <- resolveNameRecord user nm newDomain
|
||||
unless (nameResolvesTo groupLink nrSimplexChannel) $ throwChatError $ CESimplexDomainNotReady newDomain SDENoValidLink
|
||||
pure expiresAt
|
||||
runUpdateGroupProfile user gInfo p {publicGroup = Just pg {publicGroupAccess = Just access}} verifiedExpiry_
|
||||
Nothing -> throwChatError $ CECommandError "not a public group"
|
||||
APICreateGroupLink groupId mRole -> withUser $ \user -> withGroupLock "createGroupLink" groupId $ do
|
||||
gInfo@GroupInfo {groupProfile} <- withFastStore $ \db -> getGroupInfo db cxt user groupId
|
||||
@@ -4097,8 +4097,8 @@ processChatCommand cxt nm = \case
|
||||
void (sendDirectContactMessage user ct' $ XInfo p Nothing) `catchAllErrors` eToView
|
||||
lift . when (directOrUsed ct') $ createSndFeatureItems user ct ct'
|
||||
pure $ CRContactPrefsUpdated user ct ct'
|
||||
runUpdateGroupProfile :: User -> GroupInfoKeys -> GroupProfile -> Bool -> CM ChatResponse
|
||||
runUpdateGroupProfile user (GIK gInfo@GroupInfo {businessChat, groupProfile = p@GroupProfile {displayName = n}} gks) p'@GroupProfile {displayName = n', image = img', memberAdmission = ma'} domainVerified = do
|
||||
runUpdateGroupProfile :: User -> GroupInfoKeys -> GroupProfile -> Maybe (Maybe UTCTime) -> CM ChatResponse
|
||||
runUpdateGroupProfile user (GIK gInfo@GroupInfo {businessChat, groupProfile = p@GroupProfile {displayName = n}} gks) p'@GroupProfile {displayName = n', image = img', memberAdmission = ma'} verifiedExpiry_ = do
|
||||
assertUserGroupRole gInfo GROwner
|
||||
when (n /= n') $ checkValidName n'
|
||||
checkProfileImageSize img'
|
||||
@@ -4107,7 +4107,7 @@ processChatCommand cxt nm = \case
|
||||
-- updateGroupProfile clears domain verification; re-set it when the caller already re-resolved the name
|
||||
gInfo' <- withStore $ \db -> do
|
||||
g <- updateGroupProfile db user gInfo p'
|
||||
if domainVerified then liftIO $ setGroupDomainVerified db user g True else pure g
|
||||
maybe (pure g) (liftIO . setGroupDomainVerified db user g True) verifiedExpiry_
|
||||
msg <- case businessChat of
|
||||
Just BusinessChatInfo {businessId} -> do
|
||||
ms <- withStore' $ \db -> getGroupMembers db cxt user gInfo'
|
||||
@@ -4200,7 +4200,7 @@ processChatCommand cxt nm = \case
|
||||
applicable = if channel then groupFeatureInChannel feature else groupFeatureInRegularGroup feature
|
||||
unless applicable $
|
||||
throwCmdError $ T.unpack (groupFeatureNameText feature) <> " is not available in " <> (if channel then "channels" else "groups")
|
||||
runUpdateGroupProfile user gInfo (update p) False
|
||||
runUpdateGroupProfile user gInfo (update p) Nothing
|
||||
withCurrentCall :: ContactId -> (User -> Contact -> Call -> CM (Maybe Call)) -> CM ChatResponse
|
||||
withCurrentCall ctId action = do
|
||||
(user, ct) <- withStore $ \db -> do
|
||||
@@ -4411,6 +4411,24 @@ processChatCommand cxt nm = \case
|
||||
invitationReqAndPlan cReq sLnk_ cld ov = do
|
||||
plan <- invitationRequestPlan user cReq cld ov `catchAllErrors` (pure . CPError)
|
||||
pure (Just (ACCL SCMInvitation (CCLink cReq sLnk_)), Nothing, Nothing, plan)
|
||||
connectPlan user t@(ACTarget SCMContact ct) PRMUnknown sig_ Nothing
|
||||
| isName =
|
||||
tryAllErrors (connectPlan user t PRMNever sig_ Nothing) >>= \case
|
||||
Right r@(_, _, _, p) -> ifM (resolvedRecently p) (pure r) resolvePlan
|
||||
Left _ -> resolvePlan
|
||||
where
|
||||
isName = case ct of
|
||||
CTDomain _ -> True
|
||||
CTShortContact (CTName _) -> True
|
||||
_ -> False
|
||||
resolvePlan = connectPlan user t PRMAll sig_ Nothing
|
||||
resolvedRecently p = do
|
||||
resolution_ <- withFastStore' $ \db -> case p of
|
||||
CPContactAddress (CAPKnown ct') _ -> getContactDomainResolution db user ct'
|
||||
CPGroupLink (GLPKnown g _ _ _) _ -> getGroupDomainResolution db user g
|
||||
_ -> pure Nothing
|
||||
now <- liftIO getCurrentTime
|
||||
pure $ maybe False (\(resolvedAt, expiresAt_) -> diffUTCTime now resolvedAt < nominalDay && maybe True (now <) expiresAt_) resolution_
|
||||
connectPlan user (ACTarget SCMContact ct) resolveMode sig_ nameRec = case ct of
|
||||
CTDomain d
|
||||
-- local search only: look up #d then @d in the store, without online name resolution
|
||||
@@ -4466,7 +4484,7 @@ processChatCommand cxt nm = \case
|
||||
when (resolveMode == PRMNever) $ throwChatError CENotResolvedLocally
|
||||
l' <- resolveSLink
|
||||
case known_ of
|
||||
Just r | knownLinkOf r == Just l' -> pure r
|
||||
Just r@(_, p) | knownLinkOf r == Just l' -> r <$ when (isJust simplexName_) (setKnownVerified p)
|
||||
_ -> (if isJust known_ then second setAddressChanged else id) <$> resolvedPlan l'
|
||||
where
|
||||
resolvedPlan l' = do
|
||||
@@ -4476,7 +4494,7 @@ processChatCommand cxt nm = \case
|
||||
linkDomain_ = linkProfile_ >>= \Profile {contactDomain} -> claimDomain <$> contactDomain
|
||||
planDomain = case nl of CTName ni -> Just (nameDomain ni); _ -> Nothing
|
||||
refreshContact ct' = case (planDomain, linkProfile_) of
|
||||
(Just _, Just p) -> updateContactFromLinkData user ct' p
|
||||
(Just _, Just p) -> updateContactFromLinkData user ct' p expiresAt
|
||||
_ -> pure ct'
|
||||
forM_ planDomain $ \nameDomain ->
|
||||
unless (linkDomain_ == Just nameDomain) $ throwChatError $ CESimplexDomainNotReady nameDomain SDEUnknownDomain
|
||||
@@ -4519,6 +4537,11 @@ processChatCommand cxt nm = \case
|
||||
CTLink l' -> pure l'
|
||||
CTName n -> serverShortLink <$> resolveNameLink n
|
||||
con l' cReq = ACCL SCMContact $ CCLink cReq (Just l')
|
||||
expiresAt = nameExpiresAt =<< eitherToMaybe =<< nameRec
|
||||
setKnownVerified = \case
|
||||
CPContactAddress (CAPKnown ct') _ -> void $ withFastStore' $ \db -> setContactDomainVerified db user ct' True expiresAt
|
||||
CPGroupLink (GLPKnown g _ _ _) _ -> void $ withFastStore' $ \db -> setGroupDomainVerified db user g True expiresAt
|
||||
_ -> pure ()
|
||||
reResolveKnown (_, p) = resolveMode == PRMAll && case p of
|
||||
CPContactAddress (CAPKnown _) _ -> True
|
||||
CPGroupLink GLPKnown {} _ -> True
|
||||
@@ -4563,7 +4586,7 @@ processChatCommand cxt nm = \case
|
||||
-- data and mark it verified, so the check below passes and future by-name lookups match
|
||||
plan <- case (planDomain, plan0, groupSLinkData_) of
|
||||
(Just nameDomain, CPGroupLink (GLPKnown g u o os) _, Just sLinkData) ->
|
||||
(\(g', _) -> CPGroupLink (GLPKnown g' u o os) Nothing) <$> updateGroupFromLinkData user g sLinkData (Just nameDomain)
|
||||
(\(g', _) -> CPGroupLink (GLPKnown g' u o os) Nothing) <$> updateGroupFromLinkData user g sLinkData (Just nameDomain) expiresAt
|
||||
_ -> pure plan0
|
||||
forM_ planDomain $ \nameDomain ->
|
||||
let domain_ = (\GroupProfile {publicGroup} -> claimDomain <$> (publicGroup >>= publicGroupAccess >>= groupDomainClaim)) =<< case plan of
|
||||
@@ -4588,7 +4611,7 @@ processChatCommand cxt nm = \case
|
||||
let ov = verifyLinkOwner rk owners l' sig_
|
||||
glOwners = map (\OwnerAuth {ownerId, ownerKey} -> GroupLinkOwner {memberId = MemberId ownerId, memberKey = ownerKey}) owners
|
||||
(g', updated) <- case groupSLinkData_ of
|
||||
Just sLinkData -> updateGroupFromLinkData user g sLinkData Nothing
|
||||
Just sLinkData -> updateGroupFromLinkData user g sLinkData (nameDomain <$> simplexName_) expiresAt
|
||||
_ -> pure (g, False)
|
||||
pure (con l' cReq, CPGroupLink (GLPKnown g' updated ov (ListDef glOwners)) Nothing)
|
||||
-- resolve a name to its first contact/channel short link
|
||||
@@ -5111,10 +5134,10 @@ resolveNameRegistration user nm domain =
|
||||
registration <$> withAgent (\a -> resolveSimplexName a nm (aUserId user) domain)
|
||||
|
||||
-- the resolver now also reports names that are not registered, which stay the agent's NAME NOT_FOUND
|
||||
resolveNameRecord :: User -> NetworkRequestMode -> SimplexDomain -> CM NameRecord
|
||||
resolveNameRecord :: User -> NetworkRequestMode -> SimplexDomain -> CM (NameRecord, Maybe UTCTime)
|
||||
resolveNameRecord user nm domain =
|
||||
resolveNameRegistration user nm domain >>= \case
|
||||
NRRegistered {nameRecord} -> pure nameRecord
|
||||
reg@NRRegistered {nameRecord} -> pure (nameRecord, nameExpiresAt reg)
|
||||
_ -> throwError $ chatErrorAgent $ SMP "" (NAME SMP.NOT_FOUND)
|
||||
|
||||
nameExpired :: NameRegistration -> CM Bool
|
||||
@@ -5122,6 +5145,11 @@ nameExpired = \case
|
||||
NRRegistered {expires = Just expires} -> (expires <) <$> liftIO getSystemSeconds
|
||||
_ -> pure False
|
||||
|
||||
nameExpiresAt :: NameRegistration -> Maybe UTCTime
|
||||
nameExpiresAt = \case
|
||||
NRRegistered {expires} -> roundedToUTCTime <$> expires
|
||||
_ -> Nothing
|
||||
|
||||
nameHasLink :: SimplexNameType -> NameRegistration -> Bool
|
||||
nameHasLink nameType = \case
|
||||
NRRegistered {nameRecord = NameRecord {nrSimplexContact, nrSimplexChannel}} -> case nameType of
|
||||
@@ -5143,20 +5171,20 @@ setAddressChanged = \case
|
||||
CPGroupLink (GLPOk li gld ov _) nr -> CPGroupLink (GLPOk li gld ov True) nr
|
||||
p -> p
|
||||
|
||||
verifyEntityDomain :: User -> NetworkRequestMode -> SimplexNameType -> SimplexDomainClaim -> Maybe AConnShortLink -> CM (Maybe Bool, Maybe Text)
|
||||
verifyEntityDomain :: User -> NetworkRequestMode -> SimplexNameType -> SimplexDomainClaim -> Maybe AConnShortLink -> CM (Maybe (Bool, Maybe UTCTime), Maybe Text)
|
||||
verifyEntityDomain user nm nameType SimplexDomainClaim {domain = StrJSON domain, proof = proof_} connLink_ = case (proof_, connLink_) of
|
||||
(Nothing, _) -> pure (Nothing, Just "no name proof to verify")
|
||||
(_, Nothing) -> pure (Nothing, Just "no connection link to check the name against")
|
||||
(Just proof, Just (ACSL SCMContact profileSLnk)) -> do
|
||||
NameRecord {nrSimplexContact, nrSimplexChannel} <- resolveNameRecord user nm domain
|
||||
(NameRecord {nrSimplexContact, nrSimplexChannel}, expiresAt) <- resolveNameRecord user nm domain
|
||||
let resolvedLinks = case nameType of
|
||||
NTContact -> nrSimplexContact
|
||||
NTPublicGroup -> nrSimplexChannel
|
||||
if not (nameResolvesTo profileSLnk resolvedLinks)
|
||||
then pure (Just False, Just "the name does not resolve to this address")
|
||||
then pure (Just (False, expiresAt), Just "the name does not resolve to this address")
|
||||
else do
|
||||
ok <- verifyDomainProof proof profileSLnk
|
||||
pure (Just ok, if ok then Nothing else Just "the name proof was not signed by this address's owner")
|
||||
pure (Just (ok, expiresAt), if ok then Nothing else Just "the name proof was not signed by this address's owner")
|
||||
(Just _, Just _) -> pure (Nothing, Just "unexpected connection link type for name verification")
|
||||
where
|
||||
verifyDomainProof :: SimplexDomainProof -> ShortLinkContact -> CM Bool
|
||||
@@ -5777,7 +5805,7 @@ sendServiceRequestBytes nm user sendTarget requestTimeout signKey request = do
|
||||
_ -> throwCmdError "service request target must be a contact"
|
||||
CTDomain d -> resolveDomain d
|
||||
resolveDomain d = do
|
||||
nr <- resolveNameRecord user nm d
|
||||
(nr, _) <- resolveNameRecord user nm d
|
||||
case firstNameLink CCTContact (nrSimplexContact nr) of
|
||||
Just sLnk -> resolveShortLink sLnk
|
||||
Nothing -> throwChatError $ CESimplexDomainNotReady d SDENoValidLink
|
||||
|
||||
@@ -1611,8 +1611,8 @@ updatePublicGroupData user gInfo gks
|
||||
| otherwise = pure gInfo
|
||||
|
||||
-- must not resolve names here: a background link-data refresh would leak channel membership to the resolver
|
||||
updateGroupFromLinkData :: User -> GroupInfo -> GroupShortLinkData -> Maybe SimplexDomain -> CM (GroupInfo, Bool)
|
||||
updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = GroupSummary {publicMemberCount = localCount}} GroupShortLinkData {groupProfile, publicGroupData} resolvedDomain_
|
||||
updateGroupFromLinkData :: User -> GroupInfo -> GroupShortLinkData -> Maybe SimplexDomain -> Maybe UTCTime -> CM (GroupInfo, Bool)
|
||||
updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = GroupSummary {publicMemberCount = localCount}} GroupShortLinkData {groupProfile, publicGroupData} resolvedDomain_ expiresAt
|
||||
| profileChanged || countChanged || verifyResolved = do
|
||||
cxt <- chatStoreCxt
|
||||
withStore $ \db -> do
|
||||
@@ -1621,7 +1621,7 @@ updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = G
|
||||
Just PublicGroupData {publicMemberCount} | countChanged ->
|
||||
setPublicMemberCount db cxt user g publicMemberCount
|
||||
_ -> pure g
|
||||
g'' <- if verifyResolved then liftIO $ setGroupDomainVerified db user g' True else pure g'
|
||||
g'' <- if verifyResolved then liftIO $ setGroupDomainVerified db user g' True expiresAt else pure g'
|
||||
pure (g'', profileChanged)
|
||||
| otherwise = pure (gInfo, False)
|
||||
where
|
||||
@@ -1633,13 +1633,13 @@ updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = G
|
||||
newClaim = groupClaim groupProfile
|
||||
verifyResolved = isJust resolvedDomain_ && resolvedDomain_ == newClaim
|
||||
|
||||
updateContactFromLinkData :: User -> Contact -> Profile -> CM Contact
|
||||
updateContactFromLinkData user ct@Contact {profile = profile@LocalProfile {contactDomain = prevClaim, contactDomainVerified}} linkProfile@Profile {contactDomain = newClaim}
|
||||
updateContactFromLinkData :: User -> Contact -> Profile -> Maybe UTCTime -> CM Contact
|
||||
updateContactFromLinkData user ct@Contact {profile = profile@LocalProfile {contactDomain = prevClaim, contactDomainVerified}} linkProfile@Profile {contactDomain = newClaim} expiresAt
|
||||
| profileChanged || verifyChanged = do
|
||||
cxt <- chatStoreCxt
|
||||
withFastStore $ \db -> do
|
||||
ct' <- updateContactProfile db cxt user ct linkProfile
|
||||
if verifyChanged then liftIO $ setContactDomainVerified db user ct' True else pure ct'
|
||||
if verifyChanged then liftIO $ setContactDomainVerified db user ct' True expiresAt else pure ct'
|
||||
| otherwise = pure ct
|
||||
where
|
||||
profileChanged = fromLocalProfile profile /= linkProfile
|
||||
|
||||
@@ -52,6 +52,7 @@ module Simplex.Chat.Store.Direct
|
||||
getContactIdByName,
|
||||
updateContactProfile,
|
||||
setContactDomainVerified,
|
||||
getContactDomainResolution,
|
||||
updateContactUserPreferences,
|
||||
updateContactAlias,
|
||||
updateContactConnectionAlias,
|
||||
@@ -410,7 +411,7 @@ createPreparedContact db cxt user p connLinkToConnect welcomeSharedMsgId verifie
|
||||
let prepared = Just (connLinkToConnect, welcomeSharedMsgId)
|
||||
ctUserPreferences = newContactUserPrefs user p
|
||||
ct <- getContact db cxt user =<< createContact_ db cxt user p ctUserPreferences prepared "" currentTs
|
||||
liftIO $ maybe (pure ct) (setContactDomainVerified db user ct) verified_
|
||||
liftIO $ maybe (pure ct) (\v -> setContactDomainVerified db user ct v Nothing) verified_
|
||||
|
||||
updatePreparedContactUser :: DB.Connection -> StoreCxt -> User -> Contact -> User -> ExceptT StoreError IO Contact
|
||||
updatePreparedContactUser
|
||||
@@ -590,17 +591,26 @@ updateContactProfile db cxt user@User {userId} c p' = do
|
||||
clearVerificationIfClaimChanged
|
||||
pure $ Right c {localDisplayName = ldn, profile, mergedPreferences}
|
||||
|
||||
setContactDomainVerified :: DB.Connection -> User -> Contact -> Bool -> IO Contact
|
||||
setContactDomainVerified db User {userId} ct@Contact {contactId, profile = p} verified = do
|
||||
setContactDomainVerified :: DB.Connection -> User -> Contact -> Bool -> Maybe UTCTime -> IO Contact
|
||||
setContactDomainVerified db User {userId} ct@Contact {contactId, profile = p} verified expiresAt = do
|
||||
currentTs <- getCurrentTime
|
||||
DB.execute
|
||||
db
|
||||
[sql|
|
||||
UPDATE contact_profiles SET contact_domain_verified = ?
|
||||
UPDATE contact_profiles SET contact_domain_verified = ?, contact_domain_resolved_at = ?, contact_domain_expires_at = ?
|
||||
WHERE contact_profile_id IN (SELECT contact_profile_id FROM contacts WHERE user_id = ? AND contact_id = ?)
|
||||
|]
|
||||
(BI verified, userId, contactId)
|
||||
(BI verified, currentTs, expiresAt, userId, contactId)
|
||||
pure (ct {profile = p {contactDomainVerified = Just verified}} :: Contact)
|
||||
|
||||
getContactDomainResolution :: DB.Connection -> User -> Contact -> IO (Maybe (UTCTime, Maybe UTCTime))
|
||||
getContactDomainResolution db User {userId} Contact {profile = LocalProfile {profileId}} =
|
||||
maybeFirstRow id $
|
||||
DB.query
|
||||
db
|
||||
"SELECT contact_domain_resolved_at, contact_domain_expires_at FROM contact_profiles WHERE user_id = ? AND contact_profile_id = ? AND contact_domain_resolved_at IS NOT NULL"
|
||||
(userId, profileId)
|
||||
|
||||
updateContactUserPreferences :: DB.Connection -> User -> Contact -> Preferences -> IO Contact
|
||||
updateContactUserPreferences db user@User {userId} c@Contact {contactId} userPreferences = do
|
||||
updatedAt <- getCurrentTime
|
||||
|
||||
@@ -47,6 +47,7 @@ module Simplex.Chat.Store.Groups
|
||||
getGroupInfoByGroupLinkHash,
|
||||
updateGroupProfile,
|
||||
setGroupDomainVerified,
|
||||
getGroupDomainResolution,
|
||||
updateGroupPreferences,
|
||||
updateGroupProfileFromMember,
|
||||
getGroupIdByName,
|
||||
@@ -669,7 +670,7 @@ createPreparedGroup db gVar cxt user@User {userId, userContactId} groupProfile b
|
||||
-- a business has no domain in its profile, so set it out-of-band; a channel already has it (createGroup_), just verify
|
||||
g' <- liftIO $ case verifiedDomain of
|
||||
Just d | business -> setPreparedGroupDomain db user g d
|
||||
Just _ -> setGroupDomainVerified db user g True
|
||||
Just _ -> setGroupDomainVerified db user g True Nothing
|
||||
Nothing -> pure g
|
||||
pure (g', hostMember_)
|
||||
where
|
||||
@@ -2740,14 +2741,23 @@ updateGroupProfile db user@User {userId} g@GroupInfo {groupId, localDisplayName,
|
||||
(ldn, currentTs, userId, groupId)
|
||||
safeDeleteLDN db user localDisplayName
|
||||
|
||||
setGroupDomainVerified :: DB.Connection -> User -> GroupInfo -> Bool -> IO GroupInfo
|
||||
setGroupDomainVerified db User {userId} g@GroupInfo {groupId} verified = do
|
||||
setGroupDomainVerified :: DB.Connection -> User -> GroupInfo -> Bool -> Maybe UTCTime -> IO GroupInfo
|
||||
setGroupDomainVerified db User {userId} g@GroupInfo {groupId} verified expiresAt = do
|
||||
currentTs <- getCurrentTime
|
||||
DB.execute
|
||||
db
|
||||
"UPDATE groups SET group_domain_verified = ? WHERE user_id = ? AND group_id = ?"
|
||||
(BI verified, userId, groupId)
|
||||
"UPDATE groups SET group_domain_verified = ?, group_domain_resolved_at = ?, group_domain_expires_at = ? WHERE user_id = ? AND group_id = ?"
|
||||
(BI verified, currentTs, expiresAt, userId, groupId)
|
||||
pure g {groupDomainVerified = Just verified}
|
||||
|
||||
getGroupDomainResolution :: DB.Connection -> User -> GroupInfo -> IO (Maybe (UTCTime, Maybe UTCTime))
|
||||
getGroupDomainResolution db User {userId} GroupInfo {groupId} =
|
||||
maybeFirstRow id $
|
||||
DB.query
|
||||
db
|
||||
"SELECT group_domain_resolved_at, group_domain_expires_at FROM groups WHERE user_id = ? AND group_id = ? AND group_domain_resolved_at IS NOT NULL"
|
||||
(userId, groupId)
|
||||
|
||||
-- A business group has no publicGroup claim, so the domain it was connected by (from its address) is written
|
||||
-- directly to group_domain and marked verified, so it is found by the local name search (getGroupToConnect).
|
||||
setPreparedGroupDomain :: DB.Connection -> User -> GroupInfo -> SimplexDomain -> IO GroupInfo
|
||||
@@ -2759,7 +2769,7 @@ setPreparedGroupDomain db user@User {userId} g@GroupInfo {groupId} domain = do
|
||||
WHERE group_profile_id IN (SELECT group_profile_id FROM groups WHERE user_id = ? AND group_id = ?)
|
||||
|]
|
||||
(domain, userId, groupId)
|
||||
setGroupDomainVerified db user g True
|
||||
setGroupDomainVerified db user g True Nothing
|
||||
|
||||
updateGroupPreferences :: DB.Connection -> User -> GroupInfo -> GroupPreferences -> IO GroupInfo
|
||||
updateGroupPreferences db User {userId} g@GroupInfo {groupId, groupProfile = p} ps = do
|
||||
|
||||
@@ -52,6 +52,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20260828_file_expiry
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260904_file_badges
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260915_user_badges
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260918_badge_issue_errors
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260924_simplex_name_resolved
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -103,7 +104,8 @@ schemaMigrations =
|
||||
("20260828_file_expiry", m20260828_file_expiry, Just down_m20260828_file_expiry),
|
||||
("20260904_file_badges", m20260904_file_badges, Just down_m20260904_file_badges),
|
||||
("20260915_user_badges", m20260915_user_badges, Just down_m20260915_user_badges),
|
||||
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors)
|
||||
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors),
|
||||
("20260924_simplex_name_resolved", m20260924_simplex_name_resolved, Just down_m20260924_simplex_name_resolved)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260924_simplex_name_resolved where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20260924_simplex_name_resolved :: Text
|
||||
m20260924_simplex_name_resolved =
|
||||
[r|
|
||||
ALTER TABLE contact_profiles ADD COLUMN contact_domain_resolved_at TIMESTAMPTZ;
|
||||
ALTER TABLE contact_profiles ADD COLUMN contact_domain_expires_at TIMESTAMPTZ;
|
||||
|
||||
ALTER TABLE groups ADD COLUMN group_domain_resolved_at TIMESTAMPTZ;
|
||||
ALTER TABLE groups ADD COLUMN group_domain_expires_at TIMESTAMPTZ;
|
||||
|]
|
||||
|
||||
down_m20260924_simplex_name_resolved :: Text
|
||||
down_m20260924_simplex_name_resolved =
|
||||
[r|
|
||||
ALTER TABLE contact_profiles DROP COLUMN contact_domain_resolved_at;
|
||||
ALTER TABLE contact_profiles DROP COLUMN contact_domain_expires_at;
|
||||
|
||||
ALTER TABLE groups DROP COLUMN group_domain_resolved_at;
|
||||
ALTER TABLE groups DROP COLUMN group_domain_expires_at;
|
||||
|]
|
||||
@@ -680,7 +680,9 @@ CREATE TABLE test_chat_schema.contact_profiles (
|
||||
contact_domain text,
|
||||
contact_domain_proof text,
|
||||
contact_domain_verified smallint,
|
||||
description text
|
||||
description text,
|
||||
contact_domain_resolved_at timestamp with time zone,
|
||||
contact_domain_expires_at timestamp with time zone
|
||||
);
|
||||
|
||||
|
||||
@@ -1168,7 +1170,9 @@ CREATE TABLE test_chat_schema.groups (
|
||||
roster_blob bytea,
|
||||
group_domain_verified smallint,
|
||||
stored_roster_version bigint,
|
||||
applied_complete_roster_version bigint
|
||||
applied_complete_roster_version bigint,
|
||||
group_domain_resolved_at timestamp with time zone,
|
||||
group_domain_expires_at timestamp with time zone
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ import Simplex.Chat.Store.SQLite.Migrations.M20260828_file_expiry
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260904_file_badges
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260915_user_badges
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260918_badge_issue_errors
|
||||
import Simplex.Chat.Store.SQLite.Migrations.M20260924_simplex_name_resolved
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Query, Maybe Query)]
|
||||
@@ -349,7 +350,8 @@ schemaMigrations =
|
||||
("20260828_file_expiry", m20260828_file_expiry, Just down_m20260828_file_expiry),
|
||||
("20260904_file_badges", m20260904_file_badges, Just down_m20260904_file_badges),
|
||||
("20260915_user_badges", m20260915_user_badges, Just down_m20260915_user_badges),
|
||||
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors)
|
||||
("20260918_badge_issue_errors", m20260918_badge_issue_errors, Just down_m20260918_badge_issue_errors),
|
||||
("20260924_simplex_name_resolved", m20260924_simplex_name_resolved, Just down_m20260924_simplex_name_resolved)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.SQLite.Migrations.M20260924_simplex_name_resolved where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20260924_simplex_name_resolved :: Query
|
||||
m20260924_simplex_name_resolved =
|
||||
[sql|
|
||||
ALTER TABLE contact_profiles ADD COLUMN contact_domain_resolved_at TEXT;
|
||||
ALTER TABLE contact_profiles ADD COLUMN contact_domain_expires_at TEXT;
|
||||
|
||||
ALTER TABLE groups ADD COLUMN group_domain_resolved_at TEXT;
|
||||
ALTER TABLE groups ADD COLUMN group_domain_expires_at TEXT;
|
||||
|]
|
||||
|
||||
down_m20260924_simplex_name_resolved :: Query
|
||||
down_m20260924_simplex_name_resolved =
|
||||
[sql|
|
||||
ALTER TABLE contact_profiles DROP COLUMN contact_domain_resolved_at;
|
||||
ALTER TABLE contact_profiles DROP COLUMN contact_domain_expires_at;
|
||||
|
||||
ALTER TABLE groups DROP COLUMN group_domain_resolved_at;
|
||||
ALTER TABLE groups DROP COLUMN group_domain_expires_at;
|
||||
|]
|
||||
@@ -5392,7 +5392,7 @@ Plan:
|
||||
SEARCH contact_profiles USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query:
|
||||
UPDATE contact_profiles SET contact_domain_verified = ?
|
||||
UPDATE contact_profiles SET contact_domain_verified = ?, contact_domain_resolved_at = ?, contact_domain_expires_at = ?
|
||||
WHERE contact_profile_id IN (SELECT contact_profile_id FROM contacts WHERE user_id = ? AND contact_id = ?)
|
||||
|
||||
Plan:
|
||||
@@ -7451,6 +7451,10 @@ Query: SELECT connection_id FROM connections WHERE user_id = ? AND group_member_
|
||||
Plan:
|
||||
SEARCH connections USING INDEX idx_connections_group_member_id (group_member_id=?)
|
||||
|
||||
Query: SELECT contact_domain_resolved_at, contact_domain_expires_at FROM contact_profiles WHERE user_id = ? AND contact_profile_id = ? AND contact_domain_resolved_at IS NOT NULL
|
||||
Plan:
|
||||
SEARCH contact_profiles USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: SELECT contact_id FROM contacts WHERE user_id = ? AND chat_item_ttl > 0 OR chat_item_ttl IS NULL
|
||||
Plan:
|
||||
SCAN contacts
|
||||
@@ -7537,6 +7541,10 @@ Query: SELECT g.inv_queue_info FROM groups g WHERE g.group_id = ? AND g.user_id
|
||||
Plan:
|
||||
SEARCH g USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: SELECT group_domain_resolved_at, group_domain_expires_at FROM groups WHERE user_id = ? AND group_id = ? AND group_domain_resolved_at IS NOT NULL
|
||||
Plan:
|
||||
SEARCH groups USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: SELECT group_id FROM group_members WHERE group_member_id = ?
|
||||
Plan:
|
||||
SEARCH group_members USING INTEGER PRIMARY KEY (rowid=?)
|
||||
@@ -7861,6 +7869,14 @@ Query: UPDATE contact_profiles SET contact_domain = ?, updated_at = ? WHERE user
|
||||
Plan:
|
||||
SEARCH contact_profiles USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE contact_profiles SET contact_domain_expires_at = datetime('now', '-1 hours')
|
||||
Plan:
|
||||
SCAN contact_profiles
|
||||
|
||||
Query: UPDATE contact_profiles SET contact_domain_resolved_at = datetime('now', '-2 days')
|
||||
Plan:
|
||||
SCAN contact_profiles
|
||||
|
||||
Query: UPDATE contact_profiles SET image = ? WHERE display_name = ?
|
||||
Plan:
|
||||
SEARCH contact_profiles USING INDEX contact_profiles_index (display_name=?)
|
||||
@@ -8093,7 +8109,11 @@ Query: UPDATE groups SET enable_ntfs = ?, send_rcpts = ?, favorite = ? WHERE use
|
||||
Plan:
|
||||
SEARCH groups USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE groups SET group_domain_verified = ? WHERE user_id = ? AND group_id = ?
|
||||
Query: UPDATE groups SET group_domain_resolved_at = datetime('now', '-2 days')
|
||||
Plan:
|
||||
SCAN groups
|
||||
|
||||
Query: UPDATE groups SET group_domain_verified = ?, group_domain_resolved_at = ?, group_domain_expires_at = ? WHERE user_id = ? AND group_id = ?
|
||||
Plan:
|
||||
SEARCH groups USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ CREATE TABLE contact_profiles(
|
||||
contact_domain TEXT,
|
||||
contact_domain_proof TEXT,
|
||||
contact_domain_verified INTEGER,
|
||||
description TEXT
|
||||
description TEXT,
|
||||
contact_domain_resolved_at TEXT,
|
||||
contact_domain_expires_at TEXT
|
||||
) STRICT;
|
||||
CREATE TABLE users(
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
@@ -209,7 +211,9 @@ CREATE TABLE groups(
|
||||
roster_blob BLOB,
|
||||
group_domain_verified INTEGER,
|
||||
stored_roster_version INTEGER,
|
||||
applied_complete_roster_version INTEGER, -- received
|
||||
applied_complete_roster_version INTEGER,
|
||||
group_domain_resolved_at TEXT,
|
||||
group_domain_expires_at TEXT, -- received
|
||||
FOREIGN KEY(user_id, local_display_name)
|
||||
REFERENCES display_names(user_id, local_display_name)
|
||||
ON DELETE CASCADE
|
||||
|
||||
@@ -74,7 +74,6 @@ import Simplex.Messaging.Encoding
|
||||
import Simplex.Messaging.Encoding.String
|
||||
import Simplex.Messaging.Parsers (dropPrefix, taggedObjectJSON)
|
||||
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType, BlockingInfo (..), BlockingReason (..), NameRegistration (..), NamePricing (..), NetworkError (..), ProtocolServer (..), ProtocolTypeI, SProtocolType (..), USDCents (..), UserProtocol)
|
||||
import Simplex.Messaging.SimplexName (fullDomainName)
|
||||
import Simplex.Messaging.SystemTime (roundedSeconds)
|
||||
import qualified Simplex.Messaging.Protocol as SMP
|
||||
import Simplex.Messaging.Transport.Client (TransportHost (..))
|
||||
|
||||
@@ -11,6 +11,7 @@ import Control.Concurrent.Async (concurrently_)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import NameResolver
|
||||
import qualified Simplex.Messaging.Agent.Store.DB as DB
|
||||
import Simplex.Messaging.Names.Record (NameReservedReason (..))
|
||||
import Simplex.Messaging.SimplexName (SimplexDomain (..), SimplexNameInfo (..), SimplexNameType (..), SimplexTLD (..))
|
||||
import Test.Hspec hiding (it)
|
||||
@@ -38,6 +39,8 @@ chatNamesTests = do
|
||||
it "known chat, name expired" testPlanKnownNameExpired
|
||||
it "known chat, name moved to a new address" testPlanKnownNameAddressChanged
|
||||
it "known chat, name now available" testPlanKnownNameAvailable
|
||||
it "known chat, resolved over a day ago or past expiry" testPlanKnownNameStale
|
||||
it "no local chat, resolved on every call" testPlanNameResolvedEveryCall
|
||||
it "own name, live" testPlanOwnNameLive
|
||||
it "own name, expired" testPlanOwnNameExpired
|
||||
it "own name, now available" testPlanOwnNameAvailable
|
||||
@@ -255,6 +258,11 @@ testConnectByNameChannelAndContact ps = withSmpServerAndNames $ \reg ->
|
||||
bob <## "group link: known group #team"
|
||||
bob <## "SimpleX name: #team (verified)"
|
||||
bob <## "use #team <message> to send messages"
|
||||
withCCTransaction bob $ \db -> DB.execute_ db "UPDATE groups SET group_domain_resolved_at = datetime('now', '-2 days')"
|
||||
bob ##> "/_connect plan 1 team.simplex"
|
||||
bob <## "group link: known group #team"
|
||||
bob <## "SimpleX name: #team (verified)"
|
||||
bob <## "use #team <message> to send messages"
|
||||
bob <## "You can also connect to @team.simplex in direct chat"
|
||||
bob <## "registered"
|
||||
where
|
||||
@@ -429,6 +437,35 @@ testPlanKnownNameAvailable = withAliceName $ \reg _l alice bob -> do
|
||||
bob <## "use @alice <message> to send messages"
|
||||
bob <## "available: 1000 cents/year, min length 1"
|
||||
|
||||
testPlanKnownNameStale :: HasCallStack => TestParams -> IO ()
|
||||
testPlanKnownNameStale = withAliceName $ \_reg _l alice bob -> do
|
||||
connectBobByName alice bob
|
||||
planKnownAlice bob
|
||||
withCCTransaction bob $ \db -> DB.execute_ db "UPDATE contact_profiles SET contact_domain_resolved_at = datetime('now', '-2 days')"
|
||||
planKnownAlice bob
|
||||
bob <## "registered"
|
||||
planKnownAlice bob
|
||||
withCCTransaction bob $ \db -> DB.execute_ db "UPDATE contact_profiles SET contact_domain_expires_at = datetime('now', '-1 hours')"
|
||||
planKnownAlice bob
|
||||
bob <## "registered"
|
||||
planKnownAlice bob
|
||||
where
|
||||
planKnownAlice bob = do
|
||||
bob ##> "/_connect plan 1 @alice.simplex"
|
||||
bob <## "contact address: known contact alice"
|
||||
bob <## "SimpleX name: @alice.simplex (verified)"
|
||||
bob <## "use @alice <message> to send messages"
|
||||
|
||||
testPlanNameResolvedEveryCall :: HasCallStack => TestParams -> IO ()
|
||||
testPlanNameResolvedEveryCall = withAliceName $ \reg shortLink _alice bob -> do
|
||||
bob ##> "/_connect plan 1 @alice.simplex"
|
||||
bob <## "contact address: ok to connect"
|
||||
_ <- getTermLine bob
|
||||
registerExpiredName reg aliceSimplexName (contactNameRecord "alice.simplex" shortLink)
|
||||
bob ##> "/_connect plan 1 @alice.simplex"
|
||||
bob <## "SimpleX name alice.simplex: nothing to connect to"
|
||||
bob <##. "registered, expires "
|
||||
|
||||
testPlanOwnNameLive :: HasCallStack => TestParams -> IO ()
|
||||
testPlanOwnNameLive = withAliceName $ \_reg _l alice _bob -> do
|
||||
alice ##> "/_connect plan 1 @alice.simplex resolve=all"
|
||||
@@ -480,10 +517,16 @@ testPlanKnownNameAddressChanged ps = withSmpServerAndNames $ \reg ->
|
||||
bob <## "contact address: known contact alice"
|
||||
bob <## "SimpleX name: @alice.simplex (verified)"
|
||||
bob <## "use @alice <message> to send messages"
|
||||
bob <## "registered"
|
||||
bob ##> "/_connect plan 1 @alice.simplex resolve=all"
|
||||
bob <## "contact address: ok to connect, address changed"
|
||||
_ <- getTermLine bob -- the new address's short link data (JSON, printed in test view)
|
||||
withCCTransaction bob $ \db -> DB.execute_ db "UPDATE contact_profiles SET contact_domain_resolved_at = datetime('now', '-2 days')"
|
||||
bob ##> "/_connect plan 1 @alice.simplex"
|
||||
bob <## "contact address: ok to connect, address changed"
|
||||
_ <- getTermLine bob
|
||||
bob ##> "/_connect plan 1 @alice.simplex"
|
||||
bob <## "contact address: ok to connect, address changed"
|
||||
_ <- getTermLine bob
|
||||
bob ##> "/_connect plan 1 @alice.simplex resolve=never"
|
||||
bob <## "contact address: known contact alice"
|
||||
bob <## "SimpleX name: @alice.simplex (verified)"
|
||||
|
||||
Reference in new issue
Block a user