mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
cf66edb723
Added migrations for contacts and started working through thread migration (have contact and closed group threads migrating) Deprecated usage of ECKeyPair in the migrations (want to be able to remove Curve25519Kit in the future)
51 lines
1.5 KiB
Swift
51 lines
1.5 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
import SessionUtilitiesKit
|
|
|
|
public struct OpenGroup: Codable, Identifiable, FetchableRecord, PersistableRecord, TableRecord, ColumnExpressible {
|
|
public static var databaseTableName: String { "openGroup" }
|
|
static let capabilities = hasMany(Capability.self)
|
|
static let members = hasMany(GroupMember.self)
|
|
|
|
public typealias Columns = CodingKeys
|
|
public enum CodingKeys: String, CodingKey, ColumnExpression {
|
|
case server
|
|
case room
|
|
case publicKey
|
|
case name
|
|
case groupDescription = "description"
|
|
case imageId
|
|
case imageData
|
|
case userCount
|
|
case infoUpdates
|
|
}
|
|
|
|
public var id: String { "\(server).\(room)" }
|
|
|
|
public let server: String
|
|
public let room: String
|
|
public let publicKey: String
|
|
public let name: String
|
|
public let groupDescription: String?
|
|
public let imageId: Int?
|
|
public let imageData: Data?
|
|
public let userCount: Int
|
|
public let infoUpdates: Int
|
|
|
|
public var capabilities: QueryInterfaceRequest<Capability> {
|
|
request(for: OpenGroup.capabilities)
|
|
}
|
|
|
|
public var moderatorIds: QueryInterfaceRequest<GroupMember> {
|
|
request(for: OpenGroup.members)
|
|
.filter(GroupMember.Columns.role == GroupMember.Role.moderator)
|
|
}
|
|
|
|
public var adminIds: QueryInterfaceRequest<GroupMember> {
|
|
request(for: OpenGroup.members)
|
|
.filter(GroupMember.Columns.role == GroupMember.Role.admin)
|
|
}
|
|
}
|