Merge branch 'master' into remote-desktop

This commit is contained in:
Evgeny Poberezkin
2023-11-10 22:22:04 +00:00
93 changed files with 5300 additions and 1652 deletions
+7
View File
@@ -90,6 +90,7 @@ public enum ChatCommand {
case apiSetConnectionIncognito(connId: Int64, incognito: Bool)
case apiConnectPlan(userId: Int64, connReq: String)
case apiConnect(userId: Int64, incognito: Bool, connReq: String)
case apiConnectContactViaAddress(userId: Int64, incognito: Bool, contactId: Int64)
case apiDeleteChat(type: ChatType, id: Int64, notify: Bool?)
case apiClearChat(type: ChatType, id: Int64)
case apiListContacts(userId: Int64)
@@ -234,6 +235,7 @@ public enum ChatCommand {
case let .apiSetConnectionIncognito(connId, incognito): return "/_set incognito :\(connId) \(onOff(incognito))"
case let .apiConnectPlan(userId, connReq): return "/_connect plan \(userId) \(connReq)"
case let .apiConnect(userId, incognito, connReq): return "/_connect \(userId) incognito=\(onOff(incognito)) \(connReq)"
case let .apiConnectContactViaAddress(userId, incognito, contactId): return "/_connect contact \(userId) incognito=\(onOff(incognito)) \(contactId)"
case let .apiDeleteChat(type, id, notify): if let notify = notify {
return "/_delete \(ref(type, id)) notify=\(onOff(notify))"
} else {
@@ -313,6 +315,7 @@ public enum ChatCommand {
case .apiSendMessage: return "apiSendMessage"
case .apiUpdateChatItem: return "apiUpdateChatItem"
case .apiDeleteChatItem: return "apiDeleteChatItem"
case .apiConnectContactViaAddress: return "apiConnectContactViaAddress"
case .apiDeleteMemberChatItem: return "apiDeleteMemberChatItem"
case .apiChatItemReaction: return "apiChatItemReaction"
case .apiGetNtfToken: return "apiGetNtfToken"
@@ -502,6 +505,7 @@ public enum ChatResponse: Decodable, Error {
case connectionPlan(user: UserRef, connectionPlan: ConnectionPlan)
case sentConfirmation(user: UserRef)
case sentInvitation(user: UserRef)
case sentInvitationToContact(user: UserRef, contact: Contact, customUserProfile: Profile?)
case contactAlreadyExists(user: UserRef, contact: Contact)
case contactRequestAlreadyAccepted(user: UserRef, contact: Contact)
case contactDeleted(user: UserRef, contact: Contact)
@@ -653,6 +657,7 @@ public enum ChatResponse: Decodable, Error {
case .connectionPlan: return "connectionPlan"
case .sentConfirmation: return "sentConfirmation"
case .sentInvitation: return "sentInvitation"
case .sentInvitationToContact: return "sentInvitationToContact"
case .contactAlreadyExists: return "contactAlreadyExists"
case .contactRequestAlreadyAccepted: return "contactRequestAlreadyAccepted"
case .contactDeleted: return "contactDeleted"
@@ -801,6 +806,7 @@ public enum ChatResponse: Decodable, Error {
case let .connectionPlan(u, connectionPlan): return withUser(u, String(describing: connectionPlan))
case .sentConfirmation: return noDetails
case .sentInvitation: return noDetails
case let .sentInvitationToContact(u, contact, _): return withUser(u, String(describing: contact))
case let .contactAlreadyExists(u, contact): return withUser(u, String(describing: contact))
case let .contactRequestAlreadyAccepted(u, contact): return withUser(u, String(describing: contact))
case let .contactDeleted(u, contact): return withUser(u, String(describing: contact))
@@ -947,6 +953,7 @@ public enum ContactAddressPlan: Decodable {
case connectingConfirmReconnect
case connectingProhibit(contact: Contact)
case known(contact: Contact)
case contactViaAddress(contact: Contact)
}
public enum GroupLinkPlan: Decodable {
+10 -6
View File
@@ -1370,7 +1370,7 @@ public struct Contact: Identifiable, Decodable, NamedChat {
public var contactId: Int64
var localDisplayName: ContactName
public var profile: LocalProfile
public var activeConn: Connection
public var activeConn: Connection?
public var viaGroup: Int64?
public var contactUsed: Bool
public var contactStatus: ContactStatus
@@ -1384,10 +1384,10 @@ public struct Contact: Identifiable, Decodable, NamedChat {
public var id: ChatId { get { "@\(contactId)" } }
public var apiId: Int64 { get { contactId } }
public var ready: Bool { get { activeConn.connStatus == .ready } }
public var ready: Bool { get { activeConn?.connStatus == .ready } }
public var active: Bool { get { contactStatus == .active } }
public var sendMsgEnabled: Bool { get {
(ready && active && !(activeConn.connectionStats?.ratchetSyncSendProhibited ?? false))
(ready && active && !(activeConn?.connectionStats?.ratchetSyncSendProhibited ?? false))
|| nextSendGrpInv
} }
public var nextSendGrpInv: Bool { get { contactGroupMemberId != nil && !contactGrpInvSent } }
@@ -1396,14 +1396,18 @@ public struct Contact: Identifiable, Decodable, NamedChat {
public var image: String? { get { profile.image } }
public var contactLink: String? { get { profile.contactLink } }
public var localAlias: String { profile.localAlias }
public var verified: Bool { activeConn.connectionCode != nil }
public var verified: Bool { activeConn?.connectionCode != nil }
public var directOrUsed: Bool {
(activeConn.connLevel == 0 && !activeConn.viaGroupLink) || contactUsed
if let activeConn = activeConn {
(activeConn.connLevel == 0 && !activeConn.viaGroupLink) || contactUsed
} else {
true
}
}
public var contactConnIncognito: Bool {
activeConn.customUserProfileId != nil
activeConn?.customUserProfileId != nil
}
public func allowsFeature(_ feature: ChatFeature) -> Bool {