session-ios/SessionMessagingKit/Database/Models/GroupMember.swift
Morgan Pretty c80b6c720e Fixed the QA issues and a few other bugs
Updated the convoInfoVolatile to only ever set `last_read` to the maximum between the current and updated values
Fixed an issue where deleting the Note to Self and One-to-one conversations wouldn't reset the 'pinnedPriority' value
Fixed an issue with updating legacy group members and losing admin status
Fixed an issue where receiving a 'NEW' legacy group control message could revert legacy group changes
Fixed a bug where the open group suggestion grid could have broken positioning depending on the number of items
Fixed a bug where the UI wouldn't update correctly when network access was lost
Fixed a fun bug where one-to-one conversations could reappear after deletion because a new snode was polled and the latest (locally deleted) message was received again
Fixed some incorrect accessibility values
2023-03-31 12:09:04 +11:00

62 lines
1.9 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
public struct GroupMember: Codable, Equatable, Hashable, FetchableRecord, PersistableRecord, TableRecord, ColumnExpressible {
public static var databaseTableName: String { "groupMember" }
internal static let openGroupForeignKey = ForeignKey([Columns.groupId], to: [OpenGroup.Columns.threadId])
internal static let closedGroupForeignKey = ForeignKey([Columns.groupId], to: [ClosedGroup.Columns.threadId])
public static let openGroup = belongsTo(OpenGroup.self, using: openGroupForeignKey)
public static let closedGroup = belongsTo(ClosedGroup.self, using: closedGroupForeignKey)
public static let profile = hasOne(Profile.self, using: Profile.groupMemberForeignKey)
public typealias Columns = CodingKeys
public enum CodingKeys: String, CodingKey, ColumnExpression {
case groupId
case profileId
case role
case isHidden
}
public enum Role: Int, Codable, DatabaseValueConvertible {
case standard
case zombie
case moderator
case admin
}
public let groupId: String
public let profileId: String
public let role: Role
public let isHidden: Bool
// MARK: - Relationships
public var openGroup: QueryInterfaceRequest<OpenGroup> {
request(for: GroupMember.openGroup)
}
public var closedGroup: QueryInterfaceRequest<ClosedGroup> {
request(for: GroupMember.closedGroup)
}
public var profile: QueryInterfaceRequest<Profile> {
request(for: GroupMember.profile)
}
// MARK: - Initialization
public init(
groupId: String,
profileId: String,
role: Role,
isHidden: Bool
) {
self.groupId = groupId
self.profileId = profileId
self.role = role
self.isHidden = isHidden
}
}