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 #13 from NoRespect/slackFormatEscaping
Browse files Browse the repository at this point in the history
remove slackFormatEscaping
  • Loading branch information
pvzig authored Mar 18, 2018
2 parents fcf3f74 + 2e4fa97 commit b5b303c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Sources/NetworkInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public struct NetworkInterface {
// encoded when included in a query string. As a result, we need to manually apply the encoding after Apple's
// default encoding is applied.
var encodedQuery = components?.percentEncodedQuery
encodedQuery = encodedQuery?.replacingOccurrences(of: ">", with: "%3E")
encodedQuery = encodedQuery?.replacingOccurrences(of: "<", with: "%3C")
encodedQuery = encodedQuery?.replacingOccurrences(of: "@", with: "%40")

encodedQuery = encodedQuery?.replacingOccurrences(of: "?", with: "%3F")
encodedQuery = encodedQuery?.replacingOccurrences(of: "+", with: "%2B")
components?.percentEncodedQuery = encodedQuery
Expand Down
16 changes: 6 additions & 10 deletions Sources/WebAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ extension WebAPI {
public func sendMessage(
channel: String,
text: String,
escapeCharacters: Bool = true,
username: String? = nil,
asUser: Bool? = nil,
parse: ParseMode? = nil,
Expand All @@ -256,7 +255,7 @@ extension WebAPI {
let parameters: [String: Any?] = [
"token": token,
"channel": channel,
"text": escapeCharacters ? text.slackFormatEscaping : text,
"text": text,
"as_user": asUser,
"parse": parse?.rawValue,
"link_names": linkNames,
Expand All @@ -278,7 +277,6 @@ extension WebAPI {
channel: String,
thread: String,
text: String,
escapeCharacters: Bool = true,
broadcastReply: Bool = false,
username: String? = nil,
asUser: Bool? = nil,
Expand All @@ -296,7 +294,7 @@ extension WebAPI {
"token": token,
"channel": channel,
"thread_ts": thread,
"text": escapeCharacters ? text.slackFormatEscaping : text,
"text": text,
"broadcastReply": broadcastReply,
"as_user": asUser,
"parse": parse?.rawValue,
Expand All @@ -318,11 +316,10 @@ extension WebAPI {
public func sendMeMessage(
channel: String,
text: String,
escapeCharacters: Bool = true,
success: (((ts: String?, channel: String?)) -> Void)?,
failure: FailureClosure?
) {
let parameters: [String: Any?] = ["token": token, "channel": channel, "text": escapeCharacters ? text.slackFormatEscaping : text]
let parameters: [String: Any?] = ["token": token, "channel": channel, "text": text]
networkInterface.request(.chatMeMessage, parameters: parameters, successClosure: {(response) in
success?((ts: response["ts"] as? String, response["channel"] as? String))
}) {(error) in
Expand All @@ -337,15 +334,14 @@ extension WebAPI {
attachments: [Attachment?]? = nil,
parse: ParseMode = .none,
linkNames: Bool = false,
escapeCharacters: Bool = true,
success: SuccessClosure?,
failure: FailureClosure?
) {
let parameters: [String: Any?] = [
"token": token,
"channel": channel,
"ts": ts,
"text": escapeCharacters ? message.slackFormatEscaping : message,
"text": message,
"parse": parse.rawValue,
"link_names": linkNames,
"attachments": encodeAttachments(attachments)
Expand Down Expand Up @@ -460,7 +456,7 @@ extension WebAPI {
// MARK: - File Comments
extension WebAPI {
public func addFileComment(fileID: String, comment: String, success: CommentClosure?, failure: FailureClosure?) {
let parameters: [String: Any] = ["token": token, "file": fileID, "comment": comment.slackFormatEscaping]
let parameters: [String: Any] = ["token": token, "file": fileID, "comment": comment]
networkInterface.request(.filesCommentsAdd, parameters: parameters, successClosure: {(response) in
success?(Comment(comment: response["comment"] as? [String: Any]))
}) {(error) in
Expand All @@ -469,7 +465,7 @@ extension WebAPI {
}

public func editFileComment(fileID: String, commentID: String, comment: String, success: CommentClosure?, failure: FailureClosure?) {
let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID, "comment": comment.slackFormatEscaping]
let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID, "comment": comment]
networkInterface.request(.filesCommentsEdit, parameters: parameters, successClosure: {(response) in
success?(Comment(comment: response["comment"] as? [String: Any]))
}) {(error) in
Expand Down

0 comments on commit b5b303c

Please sign in to comment.