Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4 from SlackKit/threads
Browse files Browse the repository at this point in the history
Additional support for threading
  • Loading branch information
pvzig authored Jun 14, 2017
2 parents 876c506 + e8e0ea5 commit 98f7b48
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions SKCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
26113F741EF183CD007E5E45 /* Reply.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26113F731EF183CD007E5E45 /* Reply.swift */; };
2684F1A31E95AB1800536DCC /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2684F1891E95AB1800536DCC /* Action.swift */; };
2684F1A41E95AB1800536DCC /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2684F18A1E95AB1800536DCC /* Attachment.swift */; };
2684F1A51E95AB1800536DCC /* AttachmentField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2684F18B1E95AB1800536DCC /* AttachmentField.swift */; };
Expand Down Expand Up @@ -88,6 +89,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
26113F731EF183CD007E5E45 /* Reply.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reply.swift; sourceTree = "<group>"; };
2684F17D1E95AA6900536DCC /* SKCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SKCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2684F1891E95AB1800536DCC /* Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Action.swift; sourceTree = "<group>"; };
2684F18A1E95AB1800536DCC /* Attachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attachment.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -193,6 +195,7 @@
2684F1981E95AB1800536DCC /* Message.swift */,
2684F1991E95AB1800536DCC /* OAuthConfig.swift */,
2684F19A1E95AB1800536DCC /* Reaction.swift */,
26113F731EF183CD007E5E45 /* Reply.swift */,
2684F19B1E95AB1800536DCC /* RTMOptions.swift */,
2684F19C1E95AB1800536DCC /* Scope.swift */,
2684F19D1E95AB1800536DCC /* SlackError.swift */,
Expand Down Expand Up @@ -420,6 +423,7 @@
2684F1A71E95AB1800536DCC /* Channel.swift in Sources */,
2684F1AA1E95AB1800536DCC /* CustomProfileField.swift in Sources */,
2684F1B71E95AB1800536DCC /* SlackError.swift in Sources */,
26113F741EF183CD007E5E45 /* Reply.swift in Sources */,
2684F1B81E95AB1800536DCC /* Team.swift in Sources */,
2684F1A61E95AB1800536DCC /* Bot.swift in Sources */,
2684F1A41E95AB1800536DCC /* Attachment.swift in Sources */,
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions Sources/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public enum MessageSubtype: String {
case fileShare = "file_share"
case fileComment = "file_comment"
case fileMention = "file_mention"
case messageReplied = "message_replied"
case pinnedItem = "pinned_item"
case replyBroadcast = "reply_broadcast"
case unpinnedItem = "unpinned_item"
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public final class Message: Equatable {
public let type = "message"
public let subtype: String?
public var ts: String?
public var threadTs: String?
public let parentUserId: String?
public var replyCount: Int?
public var replies: [Reply]?
public let user: String?
public let channel: String?
public var hidden: Bool?
Expand Down Expand Up @@ -53,6 +57,10 @@ public final class Message: Equatable {
public init(dictionary: [String: Any]?) {
subtype = dictionary?["subtype"] as? String
ts = dictionary?["ts"] as? String
threadTs = dictionary?["thread_ts"] as? String
parentUserId = dictionary?["parent_user_id"] as? String
replyCount = dictionary?["reply_count"] as? Int
replies = (dictionary?["replies"] as? [[String: Any]])?.map({ Reply(reply: $0) })
user = dictionary?["user"] as? String
channel = dictionary?["channel"] as? String
hidden = dictionary?["hidden"] as? Bool
Expand Down Expand Up @@ -81,6 +89,8 @@ public final class Message: Equatable {

public init(ts: String?) {
self.ts = ts
threadTs = nil
parentUserId = nil
subtype = nil
user = nil
channel = nil
Expand All @@ -95,6 +105,6 @@ public final class Message: Equatable {
}

public static func == (lhs: Message, rhs: Message) -> Bool {
return lhs.ts == rhs.ts && lhs.user == rhs.user && lhs.text == rhs.text
return lhs.ts == rhs.ts && lhs.threadTs == rhs.threadTs && lhs.user == rhs.user && lhs.text == rhs.text
}
}
32 changes: 32 additions & 0 deletions Sources/Reply.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Reaction.swift
//
// Copyright © 2017 Peter Zignego. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

public struct Reply {
public let user: String?
public let ts: String?

public init(reply: [String: Any]?) {
user = reply?["user"] as? String
ts = reply?["ts"] as? String
}
}

0 comments on commit 98f7b48

Please sign in to comment.