XuqmGroup-iOSSDK/Sources/XuqmImSDK/ImTypes.swift
XuqmGroup e016adbb71 chore(ci): 更新 Jenkins 配置以支持多模块版本管理
- 为 Android、Flutter、iOS 和 RN SDK 的 Jenkinsfile 添加模块化版本控制
- 引入版本升级策略选择(major/minor/patch)和自定义版本号功能
- 实现多模块独立版本管理和选择性构建发布
- 更新 iOS SDK Package.swift 以支持独立模块化库
- 修改 iOS SDK podspec 文件以适应新的标签命名约定
- 优化 Jenkins 构建流程以支持按需选择特定模块进行构建和发布
- 修复 iOS 测试中的可选类型转换问题以提高代码健壮性
2026-05-23 01:20:57 +08:00

339 行
9.0 KiB
Swift

import Foundation
import XuqmCoreSDK
public enum ImConnectionState: String, Sendable {
case connected
case disconnected
case connecting
}
public enum ChatType: String, Codable, Sendable {
case single = "SINGLE"
case group = "GROUP"
}
public enum MsgType: String, Codable, Sendable {
case text = "TEXT"
case image = "IMAGE"
case video = "VIDEO"
case audio = "AUDIO"
case file = "FILE"
case custom = "CUSTOM"
case location = "LOCATION"
case notify = "NOTIFY"
case richText = "RICH_TEXT"
case callAudio = "CALL_AUDIO"
case callVideo = "CALL_VIDEO"
case quote = "QUOTE"
case merge = "MERGE"
case forward = "FORWARD"
case revoked = "REVOKED"
}
public enum MsgStatus: String, Codable, Sendable {
case sending = "SENDING"
case sent = "SENT"
case delivered = "DELIVERED"
case read = "READ"
case failed = "FAILED"
case revoked = "REVOKED"
}
public struct ImMessage: Codable, Sendable {
public let id: String
public let appKey: String
public let fromUserId: String
public let fromId: String?
public let toId: String
public let chatType: ChatType
public let msgType: MsgType
public let content: String
public let status: MsgStatus
public let mentionedUserIds: String?
public let groupReadCount: Int?
public let revoked: Bool?
public let createdAt: Int64
public let editedAt: Int64?
public init(
id: String,
appKey: String,
fromUserId: String,
fromId: String?,
toId: String,
chatType: ChatType,
msgType: MsgType,
content: String,
status: MsgStatus,
mentionedUserIds: String?,
groupReadCount: Int?,
revoked: Bool?,
createdAt: Int64,
editedAt: Int64?
) {
self.id = id
self.appKey = appKey
self.fromUserId = fromUserId
self.fromId = fromId
self.toId = toId
self.chatType = chatType
self.msgType = msgType
self.content = content
self.status = status
self.mentionedUserIds = mentionedUserIds
self.groupReadCount = groupReadCount
self.revoked = revoked
self.createdAt = createdAt
self.editedAt = editedAt
}
}
public struct PageResult<T: Decodable & Sendable>: Decodable, Sendable {
public let content: [T]
public let totalElements: Int64
public let totalPages: Int
public let size: Int
public let number: Int
public let numberOfElements: Int
public let first: Bool
public let last: Bool
public let empty: Bool
}
public protocol ImEventDelegate: AnyObject {
func imClientDidConnect()
func imClientDidDisconnect(reason: String?)
func imClientDidReceiveMessage(_ message: ImMessage)
func imClientDidReceiveGroupMessage(_ message: ImMessage)
func imClientDidReadMessage(_ message: ImMessage)
func imClientDidReceiveRevokedMessage(_ message: ImMessage)
func imClientDidError(_ error: String)
}
public extension ImEventDelegate {
func imClientDidReadMessage(_ message: ImMessage) {}
func imClientDidReceiveRevokedMessage(_ message: ImMessage) {}
}
public struct ImGroup: Codable, Sendable {
public let id: String
public let appKey: String
public let name: String
public let groupType: String?
public let creatorId: String
public let memberIds: String
public let adminIds: String
public let announcement: String?
public let memberInfo: String?
public let extAttributes: String?
public let createdAt: Int64
}
public struct ConversationData: Codable, Sendable {
public let targetId: String
public let chatType: ChatType
public let conversationGroup: String?
public let lastMsgContent: String?
public let lastMsgType: String?
public let lastMsgTime: Int64
public let unreadCount: Int
public let isMuted: Bool
public let isPinned: Bool
}
public struct ConversationGroupItem: Codable, Sendable {
public let targetId: String
public let chatType: ChatType
public let groupName: String
}
public struct FriendRequest: Codable, Sendable {
public let id: String
public let appKey: String
public let fromUserId: String
public let toUserId: String
public let remark: String?
public let status: String
public let createdAt: Int64
public let reviewedAt: Int64?
}
public struct GroupJoinRequest: Codable, Sendable {
public let id: String
public let appKey: String
public let groupId: String
public let requesterId: String
public let remark: String?
public let status: String
public let createdAt: Int64
public let reviewedAt: Int64?
}
public struct BlacklistEntry: Codable, Sendable {
public let id: String
public let appKey: String
public let userId: String
public let blockedUserId: String
public let createdAt: Int64
}
public struct BlacklistCheckResult: Codable, Sendable {
public let targetUserId: String
public let blockedByMe: Bool
public let blockedByTarget: Bool
public let eitherBlocked: Bool
}
public struct GroupReadReceiptSummary: Codable, Sendable {
public let messageId: String
public let groupId: String
public let memberCount: Int
public let readCount: Int
public let unreadCount: Int
}
public struct UserProfile: Codable, Sendable {
public let id: String?
public let appKey: String?
public let userId: String
public let nickname: String?
public let avatar: String?
public let gender: String?
public let status: String?
public let createdAt: Int64?
}
public struct ImSendMessageRequest: Encodable, Sendable {
public let messageId: String
public let toId: String
public let chatType: ChatType
public let msgType: MsgType
public let content: String
public let mentionedUserIds: String?
}
public struct EditMessageRequest: Encodable, Sendable {
public let content: String
}
public struct ImLoginResponse: Decodable, Sendable {
public let token: String
}
public struct ImCreateGroupRequest: Encodable, Sendable {
public let name: String
public let memberIds: [String]
public let groupType: String?
}
public struct ImUpdateGroupRequest: Encodable, Sendable {
public let name: String?
public let announcement: String?
}
public struct ImMemberRequest: Encodable, Sendable {
public let userId: String
}
public struct ImSetRoleRequest: Encodable, Sendable {
public let userId: String
public let role: String
}
public struct ImMuteMemberRequest: Encodable, Sendable {
public let userId: String
public let minutes: Int64
}
public struct ImTransferOwnerRequest: Encodable, Sendable {
public let newOwnerId: String
}
public struct ImAttributeKeysRequest: Encodable, Sendable {
public let keys: [String]
}
public struct ImGroupReadReceiptRequest: Encodable, Sendable {
public let messageIds: [String]
}
public struct BatchFriendIdsRequest: Encodable, Sendable {
public let friendIds: [String]
}
public struct BatchRequestIdsRequest: Encodable, Sendable {
public let requestIds: [String]
}
public struct BatchUserIdsRequest: Encodable, Sendable {
public let userIds: [String]
}
public struct ModifyMemberInfoRequest: Encodable, Sendable {
public let nickname: String?
public let role: String?
}
public enum ImAttributeValue: Codable, Sendable {
case string(String)
case int(Int)
case double(Double)
case bool(Bool)
case null
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if container.decodeNil() {
self = .null
} else if let value = try? container.decode(Bool.self) {
self = .bool(value)
} else if let value = try? container.decode(Int.self) {
self = .int(value)
} else if let value = try? container.decode(Double.self) {
self = .double(value)
} else {
self = .string(try container.decode(String.self))
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .string(let value):
try container.encode(value)
case .int(let value):
try container.encode(value)
case .double(let value):
try container.encode(value)
case .bool(let value):
try container.encode(value)
case .null:
try container.encodeNil()
}
}
}
extension ImAttributeValue: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self = .string(value)
}
}
extension ImAttributeValue: ExpressibleByIntegerLiteral {
public init(integerLiteral value: Int) {
self = .int(value)
}
}
extension ImAttributeValue: ExpressibleByFloatLiteral {
public init(floatLiteral value: Double) {
self = .double(value)
}
}
extension ImAttributeValue: ExpressibleByBooleanLiteral {
public init(booleanLiteral value: Bool) {
self = .bool(value)
}
}