mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
705ad11e0c
commit
0b07e34439
@ -47,7 +47,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
case phoneNumberRequest
|
case phoneNumberRequest
|
||||||
case geoProximityReached(from: PeerId, to: PeerId, distance: Int32)
|
case geoProximityReached(from: PeerId, to: PeerId, distance: Int32)
|
||||||
case groupPhoneCall(callId: Int64, accessHash: Int64, duration: Int32?)
|
case groupPhoneCall(callId: Int64, accessHash: Int64, duration: Int32?)
|
||||||
case inviteToGroupPhoneCall(callId: Int64, accessHash: Int64, peerId: PeerId)
|
case inviteToGroupPhoneCall(callId: Int64, accessHash: Int64, peerIds: [PeerId])
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
||||||
@ -103,7 +103,13 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
case 22:
|
case 22:
|
||||||
self = .groupPhoneCall(callId: decoder.decodeInt64ForKey("callId", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), duration: decoder.decodeOptionalInt32ForKey("duration"))
|
self = .groupPhoneCall(callId: decoder.decodeInt64ForKey("callId", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), duration: decoder.decodeOptionalInt32ForKey("duration"))
|
||||||
case 23:
|
case 23:
|
||||||
self = .inviteToGroupPhoneCall(callId: decoder.decodeInt64ForKey("callId", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), peerId: PeerId(decoder.decodeInt64ForKey("peerId", orElse: 0)))
|
var peerIds: [PeerId] = []
|
||||||
|
if let peerId = decoder.decodeOptionalInt64ForKey("peerId") {
|
||||||
|
peerIds.append(PeerId(peerId))
|
||||||
|
} else {
|
||||||
|
peerIds = decoder.decodeInt64ArrayForKey("peerIds").map(PeerId.init)
|
||||||
|
}
|
||||||
|
self = .inviteToGroupPhoneCall(callId: decoder.decodeInt64ForKey("callId", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), peerIds: peerIds)
|
||||||
default:
|
default:
|
||||||
self = .unknown
|
self = .unknown
|
||||||
}
|
}
|
||||||
@ -203,11 +209,11 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "duration")
|
encoder.encodeNil(forKey: "duration")
|
||||||
}
|
}
|
||||||
case let .inviteToGroupPhoneCall(callId, accessHash, peerId):
|
case let .inviteToGroupPhoneCall(callId, accessHash, peerIds):
|
||||||
encoder.encodeInt32(23, forKey: "_rawValue")
|
encoder.encodeInt32(23, forKey: "_rawValue")
|
||||||
encoder.encodeInt64(callId, forKey: "callId")
|
encoder.encodeInt64(callId, forKey: "callId")
|
||||||
encoder.encodeInt64(accessHash, forKey: "accessHash")
|
encoder.encodeInt64(accessHash, forKey: "accessHash")
|
||||||
encoder.encodeInt64(peerId.toInt64(), forKey: "peerId")
|
encoder.encodeInt64Array(peerIds.map { $0.toInt64() }, forKey: "peerIds")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,8 +231,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
return [channelId]
|
return [channelId]
|
||||||
case let .geoProximityReached(from, to, _):
|
case let .geoProximityReached(from, to, _):
|
||||||
return [from, to]
|
return [from, to]
|
||||||
case let .inviteToGroupPhoneCall(_, _, peerId):
|
case let .inviteToGroupPhoneCall(_, _, peerIds):
|
||||||
return [peerId]
|
return peerIds
|
||||||
default:
|
default:
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -787,7 +787,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-202219658] = { return Api.MessageAction.parse_messageActionContactSignUp($0) }
|
dict[-202219658] = { return Api.MessageAction.parse_messageActionContactSignUp($0) }
|
||||||
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
||||||
dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) }
|
dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) }
|
||||||
dict[254144570] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) }
|
dict[1991897370] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) }
|
||||||
dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) }
|
dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) }
|
||||||
dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) }
|
dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) }
|
||||||
dict[-2014659757] = { return Api.PhoneCall.parse_phoneCallRequested($0) }
|
dict[-2014659757] = { return Api.PhoneCall.parse_phoneCallRequested($0) }
|
||||||
|
@ -21451,7 +21451,7 @@ public extension Api {
|
|||||||
case messageActionContactSignUp
|
case messageActionContactSignUp
|
||||||
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
||||||
case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?)
|
case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?)
|
||||||
case messageActionInviteToGroupCall(call: Api.InputGroupCall, userId: Int32)
|
case messageActionInviteToGroupCall(call: Api.InputGroupCall, users: [Int32])
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -21639,12 +21639,16 @@ public extension Api {
|
|||||||
call.serialize(buffer, true)
|
call.serialize(buffer, true)
|
||||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)}
|
||||||
break
|
break
|
||||||
case .messageActionInviteToGroupCall(let call, let userId):
|
case .messageActionInviteToGroupCall(let call, let users):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(254144570)
|
buffer.appendInt32(1991897370)
|
||||||
}
|
}
|
||||||
call.serialize(buffer, true)
|
call.serialize(buffer, true)
|
||||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(users.count))
|
||||||
|
for item in users {
|
||||||
|
serializeInt32(item, buffer: buffer, boxed: false)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21701,8 +21705,8 @@ public extension Api {
|
|||||||
return ("messageActionGeoProximityReached", [("fromId", fromId), ("toId", toId), ("distance", distance)])
|
return ("messageActionGeoProximityReached", [("fromId", fromId), ("toId", toId), ("distance", distance)])
|
||||||
case .messageActionGroupCall(let flags, let call, let duration):
|
case .messageActionGroupCall(let flags, let call, let duration):
|
||||||
return ("messageActionGroupCall", [("flags", flags), ("call", call), ("duration", duration)])
|
return ("messageActionGroupCall", [("flags", flags), ("call", call), ("duration", duration)])
|
||||||
case .messageActionInviteToGroupCall(let call, let userId):
|
case .messageActionInviteToGroupCall(let call, let users):
|
||||||
return ("messageActionInviteToGroupCall", [("call", call), ("userId", userId)])
|
return ("messageActionInviteToGroupCall", [("call", call), ("users", users)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22016,12 +22020,14 @@ public extension Api {
|
|||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
_1 = Api.parse(reader, signature: signature) as? Api.InputGroupCall
|
_1 = Api.parse(reader, signature: signature) as? Api.InputGroupCall
|
||||||
}
|
}
|
||||||
var _2: Int32?
|
var _2: [Int32]?
|
||||||
_2 = reader.readInt32()
|
if let _ = reader.readInt32() {
|
||||||
|
_2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||||
|
}
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
if _c1 && _c2 {
|
if _c1 && _c2 {
|
||||||
return Api.MessageAction.messageActionInviteToGroupCall(call: _1!, userId: _2!)
|
return Api.MessageAction.messageActionInviteToGroupCall(call: _1!, users: _2!)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -7303,12 +7303,16 @@ public extension Api {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func inviteToGroupCall(call: Api.InputGroupCall, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
public static func inviteToGroupCall(call: Api.InputGroupCall, users: [Api.InputUser]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(-580284540)
|
buffer.appendInt32(2067345760)
|
||||||
call.serialize(buffer, true)
|
call.serialize(buffer, true)
|
||||||
userId.serialize(buffer, true)
|
buffer.appendInt32(481674261)
|
||||||
return (FunctionDescription(name: "phone.inviteToGroupCall", parameters: [("call", call), ("userId", userId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
buffer.appendInt32(Int32(users.count))
|
||||||
|
for item in users {
|
||||||
|
item.serialize(buffer, true)
|
||||||
|
}
|
||||||
|
return (FunctionDescription(name: "phone.inviteToGroupCall", parameters: [("call", call), ("users", users)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||||
let reader = BufferReader(buffer)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.Updates?
|
var result: Api.Updates?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
|
@ -1001,7 +1001,7 @@ public func inviteToGroupCall(account: Account, callId: Int64, accessHash: Int64
|
|||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
|
|
||||||
return account.network.request(Api.functions.phone.inviteToGroupCall(call: .inputGroupCall(id: callId, accessHash: accessHash), userId: apiUser))
|
return account.network.request(Api.functions.phone.inviteToGroupCall(call: .inputGroupCall(id: callId, accessHash: accessHash), users: [apiUser]))
|
||||||
|> mapError { _ -> InviteToGroupCallError in
|
|> mapError { _ -> InviteToGroupCallError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionInviteToGroupCall:
|
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall:
|
||||||
break
|
break
|
||||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId))
|
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId))
|
||||||
@ -209,6 +209,10 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
|||||||
case let .messageActionGeoProximityReached(fromId, toId, _):
|
case let .messageActionGeoProximityReached(fromId, toId, _):
|
||||||
result.append(fromId.peerId)
|
result.append(fromId.peerId)
|
||||||
result.append(toId.peerId)
|
result.append(toId.peerId)
|
||||||
|
case let .messageActionInviteToGroupCall(_, userIds):
|
||||||
|
for id in userIds {
|
||||||
|
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: id))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -64,10 +64,12 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
|||||||
case let .inputGroupCall(id, accessHash):
|
case let .inputGroupCall(id, accessHash):
|
||||||
return TelegramMediaAction(action: .groupPhoneCall(callId: id, accessHash: accessHash, duration: duration))
|
return TelegramMediaAction(action: .groupPhoneCall(callId: id, accessHash: accessHash, duration: duration))
|
||||||
}
|
}
|
||||||
case let .messageActionInviteToGroupCall(call, userId):
|
case let .messageActionInviteToGroupCall(call, userIds):
|
||||||
switch call {
|
switch call {
|
||||||
case let .inputGroupCall(id, accessHash):
|
case let .inputGroupCall(id, accessHash):
|
||||||
return TelegramMediaAction(action: .inviteToGroupPhoneCall(callId: id, accessHash: accessHash, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)))
|
return TelegramMediaAction(action: .inviteToGroupPhoneCall(callId: id, accessHash: accessHash, peerIds: userIds.map { userId in
|
||||||
|
PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -459,14 +459,22 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
} else {
|
} else {
|
||||||
attributedString = addAttributesToStringWithRanges(strings.Notification_ProximityReached(message.peers[fromId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? "", distanceString, message.peers[toId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? ""), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, fromId), (2, toId)]))
|
attributedString = addAttributesToStringWithRanges(strings.Notification_ProximityReached(message.peers[fromId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? "", distanceString, message.peers[toId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? ""), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, fromId), (2, toId)]))
|
||||||
}
|
}
|
||||||
case let .inviteToGroupPhoneCall(_, _, userId):
|
case let .inviteToGroupPhoneCall(_, _, peerIds):
|
||||||
if message.author?.id == accountPeerId {
|
var attributePeerIds: [(Int, PeerId?)] = [(0, message.author?.id)]
|
||||||
attributedString = addAttributesToStringWithRanges(strings.Notification_VoiceChatInvitationByYou( message.peers[userId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? ""), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, userId)]))
|
let resultTitleString: (String, [(Int, NSRange)])
|
||||||
} else if userId == accountPeerId {
|
if peerIds.count == 1 {
|
||||||
attributedString = addAttributesToStringWithRanges(strings.Notification_VoiceChatInvitationForYou(authorName), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
|
if peerIds[0] == accountPeerId {
|
||||||
|
attributePeerIds.append((1, peerIds.first))
|
||||||
|
resultTitleString = strings.Notification_VoiceChatInvitationForYou(authorName)
|
||||||
|
} else {
|
||||||
|
attributePeerIds.append((1, peerIds.first))
|
||||||
|
resultTitleString = strings.Notification_VoiceChatInvitation(authorName, peerDebugDisplayTitles(peerIds, message.peers))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
attributedString = addAttributesToStringWithRanges(strings.Notification_VoiceChatInvitation(authorName, message.peers[userId]?.displayTitle(strings: strings, displayOrder: nameDisplayOrder) ?? ""), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id), (1, userId)]))
|
resultTitleString = strings.Notification_VoiceChatInvitation(authorName, peerDebugDisplayTitles(peerIds, message.peers))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attributedString = addAttributesToStringWithRanges(resultTitleString, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: attributePeerIds))
|
||||||
case .unknown:
|
case .unknown:
|
||||||
attributedString = nil
|
attributedString = nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user