-
Notifications
You must be signed in to change notification settings - Fork 11
#1231 Add API endpoints for messages uploading #1261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
19f34b4
#1615 API endpoints for uploading messages
sosnovsky 5036c0b
Merge branch 'master' into feature/issue-1615-password-api
sosnovsky bc7920f
Merge branch 'master' into feature/issue-1615-password-api
sosnovsky af0b081
Merge branch 'master' into feature/issue-1615-password-api
sosnovsky de75b9e
#1615 add uploadMessage endpoint
sosnovsky 01a891e
Merge branch 'master' into feature/issue-1615-password-api
sosnovsky 2a0d73f
#1615 update upload message request
sosnovsky 5967073
#1615 add MultipartDataRequest
sosnovsky 666b317
#1615 remove test code
sosnovsky 3385f7d
Merge branch 'master' into feature/issue-1615-password-api
sosnovsky e7d4d3f
#1615 pr updates
sosnovsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...rypt/Functionality/Services/Account Server Services/Models/EnterpriseServerApiError.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // | ||
| // EnterpriseServerApiError.swift | ||
| // FlowCrypt | ||
| // | ||
| // Created by Roma Sosnovsky on 27/12/21 | ||
| // Copyright © 2017-present FlowCrypt a. s. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum EnterpriseServerApiError: Error { | ||
| case parse | ||
| case emailFormat | ||
| case noActiveFesUrl | ||
| } | ||
|
|
||
| extension EnterpriseServerApiError: LocalizedError { | ||
| var errorDescription: String? { | ||
| switch self { | ||
| case .parse: return "organisational_rules_parse_error_description".localized | ||
| case .emailFormat: return "organisational_rules_email_format_error_description".localized | ||
| case .noActiveFesUrl: return "organisational_rules_fes_url_error_description".localized | ||
| } | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
FlowCrypt/Functionality/Services/Account Server Services/Models/MessageUploadDetails.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // | ||
| // MessageUploadDetails.swift | ||
| // FlowCrypt | ||
| // | ||
| // Created by Roma Sosnovsky on 30/12/21 | ||
| // Copyright © 2017-present FlowCrypt a. s. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct MessageUploadDetails: Encodable { | ||
| let associateReplyToken: String | ||
| let from: String | ||
| let to: [String] | ||
| let cc: [String] | ||
| let bcc: [String] | ||
| } |
39 changes: 39 additions & 0 deletions
39
FlowCrypt/Functionality/Services/Account Server Services/Models/MultipartDataRequest.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // | ||
| // MultipartDataRequest.swift | ||
| // FlowCrypt | ||
| // | ||
| // Created by Roma Sosnovsky on 27/12/21 | ||
| // Copyright © 2017-present FlowCrypt a. s. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct MultipartDataRequest { | ||
| private let lineSeparator = "\r\n" | ||
|
|
||
| let boundary = UUID().uuidString | ||
| let httpBody = NSMutableData() | ||
|
|
||
| init(items: [MultipartDataItem]) { | ||
| items.forEach(append) | ||
| appendBoundary() | ||
| } | ||
|
|
||
| private func append(item: MultipartDataItem) { | ||
| httpBody.append("--\(boundary)\(lineSeparator)") | ||
| httpBody.append("Content-Disposition: form-data; name=\"\(item.name)\"; filename=\"\(item.name)\"\(lineSeparator)") | ||
| httpBody.append("Content-Type: \(item.contentType)\(lineSeparator)\(lineSeparator)") | ||
| httpBody.append(item.data) | ||
| httpBody.append(lineSeparator) | ||
| } | ||
|
|
||
| private func appendBoundary() { | ||
| httpBody.append("--\(boundary)--\(lineSeparator)") | ||
| } | ||
| } | ||
|
|
||
| struct MultipartDataItem { | ||
| let data: Data | ||
| let name: String | ||
| let contentType: String | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,4 +53,12 @@ final class EnterpriseServerApiMock: EnterpriseServerApiType { | |
| getClientConfigurationForCurrentUserCount += 1 | ||
| return try getClientConfigurationForCurrentUserCall() | ||
| } | ||
|
|
||
| func getReplyToken(for email: String) async throws -> String { | ||
| return "" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better mock value would be |
||
| } | ||
|
|
||
| func upload(message: Data, details: MessageUploadDetails) async throws -> String { | ||
| return "" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a subtle thing:
fromandcurrent accountmay not be the same thing in the future - once we add support for differentsendAsaliases, in which case you may send an email fromalias@example.comwhile on accountaccount@example.com. So this would really need anaccountandfromseparately, or in the future maybeidTokenandfromseparately. For now though, it's ok. I'll file an issue.