Skip to content

Commit

Permalink
add refreshAttachmentWithID
Browse files Browse the repository at this point in the history
  • Loading branch information
nixzhu committed Feb 1, 2016
1 parent 70b6759 commit 54e5612
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
19 changes: 19 additions & 0 deletions Yep/Services/YepService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2748,6 +2748,25 @@ func deleteMessageFromServer(messageID messageID: String, failureHandler: ((Reas
}
}

func refreshAttachmentWithID(attachmentID: String, failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {

let requestParameters = [
"ids": [attachmentID],
]

let parse: JSONDictionary -> JSONDictionary? = { data in
return data
}

let resource = authJsonResource(path: "/v1/attachments/refresh_url", method: .PATCH, requestParameters: requestParameters, parse: parse)

if let failureHandler = failureHandler {
apiRequest({_ in}, baseURL: yepBaseURL, resource: resource, failure: failureHandler, completion: completion)
} else {
apiRequest({_ in}, baseURL: yepBaseURL, resource: resource, failure: defaultFailureHandler, completion: completion)
}
}

// MARK: - Feeds

enum FeedSortStyle: String {
Expand Down
12 changes: 0 additions & 12 deletions Yep/Services/YepServiceSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -864,18 +864,6 @@ func recordMessageWithMessageID(messageID: String, detailInfo messageInfo: JSOND

for attachmentInfo in attachments {

// S3: normal file
// if let
// normalFileInfo = attachmentInfo["file"] as? JSONDictionary,
// fileURLString = normalFileInfo["url"] as? String,
// kind = attachmentInfo["kind"] as? String {
// if kind == "thumbnail" {
// message.thumbnailURLString = fileURLString
// } else {
// message.attachmentURLString = fileURLString
// }
// }

if let attachmentID = attachmentInfo["id"] as? String {
message.attachmentID = attachmentID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ class ConversationsViewController: SegueViewController {
}

isFirstAppear = false

// test
refreshAttachmentWithID("e6b3cc469c7888a0f75d7f45ba35f6e8", failureHandler: nil, completion: { newAttachmentInfo in
println("newAttachmentInfo: \(newAttachmentInfo)")
})
}

private func askForNotification() {
Expand Down

0 comments on commit 54e5612

Please sign in to comment.