Skip to content

Commit

Permalink
Version 3.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
webim committed Dec 10, 2018
1 parent 20c94fb commit 2ad3c08
Show file tree
Hide file tree
Showing 17 changed files with 740 additions and 26 deletions.
134 changes: 134 additions & 0 deletions Documentation/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
- [send(message:data:completionHandler:) method](#send-message-data)
- [send(message:isHintQuestion:) method](#send-message-is-hint-question)
- [send(file:filename:mimeType:completionHandler:) method](#send-file-filename-mime-type-completion-handler)
- [edit(message:text:completionHandler:) method](#edit-message)
- [delete(message:completionHandler:) method](#delete-message)
- [setChatRead() method](#set-chat-read)
- [set(prechatFields:) method](#set-prechat-fields)
- [newMessageTracker(messageListener:) method](#new-message-tracker-message-listener)
Expand All @@ -88,6 +90,12 @@
- [DataMessageCompletionHandler protocol](#data-message-completion-handler)
- [onSuccess(messageID:) method](#on-success-message-id-data-message-completion-handler)
- [onFailure(messageID:,error:) method](#on-failure-message-id-error-data-message-completion-handler)
- [EditMessageCompletionHandler protocol](#edit-message-completion-handler)
- [onSuccess(messageID:) method](#on-success-message-id-edit-message-completion-handler)
- [onFailure(messageID:,error:) method](#on-failure-message-id-error-edit-message-completion-handler)
- [DeleteMessageCompletionHandler protocol](#delete-message-completion-handler)
- [onSuccess(messageID:) method](#on-success-message-id-delete-message-completion-handler)
- [onFailure(messageID:,error:) method](#on-failure-message-id-error-delete-message-completion-handler)
- [SendFileCompletionHandler protocol](#send-file-completion-handler)
- [onSuccess(messageID:) method](#on-success-message-id)
- [onFailure(messageID:,error:) method](#on-failure-message-id-error)
Expand Down Expand Up @@ -145,6 +153,18 @@
- [QUOTED_MESSAGE_MULTIPLE_IDS case](#quoted-message-multiple-ids)
- [QUOTED_MESSAGE_REQUIRED_ARGUMENTS_MISSING case](#quoted-message-required-arguments-missing)
- [QUOTED_MESSAGE_WRONG_ID case](#quoted-message-wrong-id)
- [EditMessageError enum](#edit-message-error)
- [UNKNOWN case](#unknown-edit-message-error)
- [NOT_ALLOWED case](#not-allowed-edit-message-error)
- [MESSAGE_EMPTY case](#message_empty-edit-message-error)
- [MESSAGE_NOT_OWNED case](#message-not-owned-edit-message-error)
- [MAX_LENGTH_EXCEEDED case](#max-length-exceeded-edit-message-error)
- [WRONG_MESSAGE_KIND case](#wrong-message-kind-edit-message-error)
- [DeleteMessageError enum](#delete-message-error)
- [UNKNOWN case](#unknown-delete-message-error)
- [NOT_ALLOWED case](#not-allowed-delete-message-error)
- [MESSAGE_NOT_OWNED case](#message-not-owned-delete-message-error)
- [MESSAGE_NOT_FOUND](#message-not-found-delete-message-error)
- [SendFileError enum](#send-file-error)
- [FILE_SIZE_EXCEEDED case](#file-size-exceeded)
- [FILE_TYPE_NOT_ALLOWED case](#file-type-not-allowed)
Expand Down Expand Up @@ -177,6 +197,7 @@
- [getType() method](#get-type)
- [isEqual(to:) method](#is-equal-to-message)
- [isReadByOperator() method](#is-read-by-operator)
- [canBeEdited() method](#can-be-edited)
- [MessageAttachment protocol](#message-attachment)
- [getContentType() method](#get-content-type)
- [getFileName() method](#get-file-name)
Expand Down Expand Up @@ -669,6 +690,27 @@ When calling this method, if there is an active [MessageTracker](#message-tracke
Returns randomly generated `String`-typed ID of the message.
Can throw errors of [AccessError](#access-error) type.

<h3 id ="edit-message">edit(message:text:completionHandler:) method</h3>

Edits a text message.
Before calling this method recommended to find out the possibility of editing the message using [canBeEdited() method](#can-be-edited).
When calling this method, if there is an active [MessageTracker](#message-tracker) object. [changed(message:,to:) method](changed-message-old-version-to-new-version) with a message [SENDING case](#sending) in the status is also called.
`message` parameter – message in `Message` type.
`text` parameter – new message text of `String` type.
`completionHandler` parameter – optional [EditMessageCompletionHandler](#edit-message-completion-handler) object.
Returns true if message can be edited.
Can throw errors of [AccessError](#access-error) type.

<h3 id ="delete-message">edit(message:text:completionHandler:) method</h3>

Deletes a text message.
Before calling this method recommended to find out the possibility of editing the message using [canBeEdited() method](#can-be-edited).
When calling this method, if there is an active [MessageTracker](#message-tracker) object. [removed(message:) method](#removed-message) with a message [SENT case](#sent) in the status is also called.
`message` parameter – message in `Message` type.
`completionHandler` parameter – optional [DeleteMessageCompletionHandler](#delete-message-completion-handler) object.
Returns true if message can be deleted.
Can throw errors of [AccessError](#access-error) type.

<h3 id ="set-chat-read">setChatRead() method</h3>

Set chat has been read by visitor.
Expand Down Expand Up @@ -745,6 +787,40 @@ Executed when operation is failed.

[Go to table of contents](#table-of-contents)

<h2 id ="edit-message-completion-handler">EditMessageCompletionHandler protocol</h2>

Protocol which methods are called after [edit(message:text:completionHandler:)](#edit-message) method is finished. Must be adopted.

<h3 id ="on-success-message-id-edit-message-completion-handler">onSuccess(messageID:) method</h3>

Executed when operation is done successfully.
`messageID` parameter – ID of the appropriate message of `String` type.

<h3 id ="on-failure-message-id-error-edit-message-completion-handler">onFailure(messageID:error:) method</h3>

Executed when operation is failed.
`messageID` parameter – ID of the appropriate message of `String` type.
`error` parameter – appropriate [EditMessageError](#edit-message-error) value.

[Go to table of contents](#table-of-contents)

<h2 id ="delete-message-completion-handler">DeleteMessageCompletionHandler protocol</h2>

Protocol which methods are called after [delete(message:completionHandler:)](#delete-message) method is finished. Must be adopted.

<h3 id ="on-success-message-id-delete-message-completion-handler">onSuccess(messageID:) method</h3>

Executed when operation is done successfully.
`messageID` parameter – ID of the appropriate message of `String` type.

<h3 id ="on-failure-message-id-error-delete-message-completion-handler">onFailure(messageID:error:) method</h3>

Executed when operation is failed.
`messageID` parameter – ID of the appropriate message of `String` type.
`error` parameter – appropriate [DeleteMessageError](#delete-message-error) value.

[Go to table of contents](#table-of-contents)

<h2 id ="send-file-completion-handler">SendFileCompletionHandler protocol</h2>

Protocol which methods are called after [send(file:filename:mimeType:completionHandler:)](#send-file-filename-mime-type-completion-handler) method is finished. Must be adopted.
Expand Down Expand Up @@ -1050,6 +1126,58 @@ To be raised when wrong quoted message ID is sent.

[Go to table of contents](#table-of-contents)

<h2 id ="data-message-error">EditMessageError enum</h2>

Error types that could be passed in [onFailure(messageID:error:) method](#on-failure-message-id-error-edit-message-completion-handler).

<h3 id ="unknown-edit-message-error">UNKNOWN case</h3>

Received error is not supported by current WebimClientLibrary version.

<h3 id="not-allowed-edit-message-error">NOT_ALLOWED case</h3>

Editing messages by visitor is turned off on the server.

<h3 id=message-empty-edit-message-error">MESSAGE_EMPTY case</h3>

Editing message is empty.

<h3 id=message-not-owned-edit-message-error">MESSAGE_NOT_OWNED case</h3>

Visitor can edit only his messages. The specified id belongs to someone else's message.

<h3 id=max-length-exceeded-edit-message-error">MAX_LENGTH_EXCEEDED case</h3>

The server may deny a request if the message size exceeds a limit. The maximum size of a message is configured on the server.

<h3 id=wrong-message-kind-edit-message-error">WRONG_MESSAGE_KIND case</h3>

Visitor can edit only text messages.

[Go to table of contents](#table-of-contents)

<h2 id ="delete-message-error">DeleteMessageError enum</h2>

Error types that could be passed in [onFailure(messageID:error:) method](#on-failure-message-id-error-delete-message-completion-handler).

<h3 id ="unknown-delete-message-error">UNKNOWN case</h3>

Received error is not supported by current WebimClientLibrary version.

<h3 id="not-allowed-delete-message-error">NOT_ALLOWED case</h3>

Editing messages by visitor is turned off on the server.

<h3 id=message-not-owned-delete-message-error">MESSAGE_NOT_OWNED case</h3>

Visitor can edit only his messages. The specified id belongs to someone else's message.

<h3 id=max-length-exceeded-edit-message-error">MESSAGE_NOT_FOUND case</h3>

Message with the specified id is not found in history.

[Go to table of contents](#table-of-contents)

<h2 id ="send-file-error">SendFileError enum</h2>

Error types that could be passed in [onFailure(messageID:error:) method](#on-failure-message-id-error).
Expand Down Expand Up @@ -1226,6 +1354,12 @@ Returns true if visitor message read by operator or this message is not by visit

[Go to table of contents](#table-of-contents)

<h3 id ="can-be-edited">canBeEdited() method</h3>

Returns true if message can be edited and false otherwise.

[Go to table of contents](#table-of-contents)

<h2 id ="message-attachment">MessageAttachment protocol</h2>

Contains information about an attachment file.
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.22.3</string>
<string>3.23.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ This library provides [_Webim SDK_ for _iOS_](https://webim.ru/integration/mobil

Add following line for your target in your **Podfile**:
```
pod 'WebimClientLibrary', :git => 'https://github.com/webim/webim-client-sdk-ios.git', :branch => 'master', :tag => '3.22.3'
pod 'WebimClientLibrary', :git => 'https://github.com/webim/webim-client-sdk-ios.git', :branch => 'master', :tag => '3.23.0'
```
`use_frameworks!` must be specified.

### Carthage

Add following line to your **Cartfile**:
```
github "webim/webim-client-sdk-ios" ~> 3.22.3
github "webim/webim-client-sdk-ios" ~> 3.23.0
```

### Additional notes
Expand All @@ -38,8 +38,9 @@ Trying to integrate _WebimClientLibrary_ into your _Objective-C_ code? Try out o
Previous _Objective-C_ version (version numbers 2.x.x) can be reached from **version2** branch.

## Release notes
* History upload bug fixed.
* FileSendCompletionHandler bug fixed.
* New method `edit(message:text:completionHandler:)`.
* New method `delete(message:completionHandler:)`.
* New method `canBeEdited()`.

## Example

Expand Down
2 changes: 1 addition & 1 deletion WebimClientLibrary.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'WebimClientLibrary'
s.version = '3.22.3'
s.version = '3.23.0'

s.author = { 'Webim.ru Ltd.' => '[email protected]' }
s.homepage = 'https://webim.ru/integration/mobile-sdk/ios-sdk-howto/'
Expand Down
71 changes: 69 additions & 2 deletions WebimClientLibrary/Backend/ActionRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ class ActionRequestLoop: AbstractRequestLoop {

break
case WebimInternalError.fileSizeExceeded.rawValue,
WebimInternalError.fileTypeNotAllowed.rawValue:
WebimInternalError.fileTypeNotAllowed.rawValue,
WebimInternalError.uploadedFileNotFound.rawValue,
WebimInternalError.notAllowedMimeType.rawValue,
WebimInternalError.notMatchingMagicNumbers.rawValue:
self.handleSendFile(error: error,
ofRequest: request)

Expand All @@ -159,6 +162,12 @@ class ActionRequestLoop: AbstractRequestLoop {
ofRequest: request)

break
case WebimInternalError.messageNotFound.rawValue,
WebimInternalError.notAllowed.rawValue,
WebimInternalError.messageNotOwned.rawValue:
self.handleDeleteMessage(error: error,
ofRequest: request)
break
default:
self.running = false

Expand Down Expand Up @@ -280,6 +289,62 @@ class ActionRequestLoop: AbstractRequestLoop {
}
}

private func handleEditMessage(error errorString: String,
ofRequest webimRequest: WebimRequest) {
if let editMessageCompletionHandler = webimRequest.getEditMessageCompletionHandler() {
completionHandlerExecutor.execute(task: DispatchWorkItem {
let editMessageError: EditMessageError
switch errorString {
case WebimInternalError.messageEmpty.rawValue:
editMessageError = .MESSAGE_EMPTY
break
case WebimInternalError.maxMessageLengthExceeded.rawValue:
editMessageError = .MAX_LENGTH_EXCEEDED
break
case WebimInternalError.notAllowed.rawValue:
editMessageError = .NOT_ALLOWED
break
case WebimInternalError.messageNotOwned.rawValue:
editMessageError = .MESSAGE_NOT_OWNED
break
case WebimInternalError.wrongMessageKind.rawValue:
editMessageError = .WRONG_MESSAGE_KIND
break
default:
editMessageError = .UNKNOWN
}

editMessageCompletionHandler.onFailure(messageID: webimRequest.getMessageID()!,
error: editMessageError)
})
}
}

private func handleDeleteMessage(error errorString: String,
ofRequest webimRequest: WebimRequest) {
if let deleteMessageCompletionHandler = webimRequest.getDeleteMessageCompletionHandler() {
completionHandlerExecutor.execute(task: DispatchWorkItem {
let deleteMessageError: DeleteMessageError
switch errorString {
case WebimInternalError.messageNotFound.rawValue:
deleteMessageError = .MESSAGE_NOT_FOUND
break
case WebimInternalError.notAllowed.rawValue:
deleteMessageError = .NOT_ALLOWED
break
case WebimInternalError.messageNotOwned.rawValue:
deleteMessageError = .MESSAGE_NOT_OWNED
break
default:
deleteMessageError = .UNKNOWN
}

deleteMessageCompletionHandler.onFailure(messageID: webimRequest.getMessageID()!,
error: deleteMessageError)
})
}
}

private func handleSendFile(error errorString: String,
ofRequest webimRequest: WebimRequest) {
if let sendFileCompletionHandler = webimRequest.getSendFileCompletionHandler() {
Expand Down Expand Up @@ -312,9 +377,11 @@ class ActionRequestLoop: AbstractRequestLoop {

private func handleClientCompletionHandlerOf(request: WebimRequest) {
completionHandlerExecutor.execute(task: DispatchWorkItem {
request.getDataMessageCompletionHandler()?.onSussess(messageID: request.getMessageID()!)
request.getDataMessageCompletionHandler()?.onSuccess(messageID: request.getMessageID()!)
request.getSendFileCompletionHandler()?.onSuccess(messageID: request.getMessageID()!)
request.getRateOperatorCompletionHandler()?.onSuccess()
request.getDeleteMessageCompletionHandler()?.onSuccess(messageID: request.getMessageID()!)
request.getEditMessageCompletionHandler()?.onSuccess(messageID: request.getMessageID()!)
})
}

Expand Down
Loading

0 comments on commit 2ad3c08

Please sign in to comment.