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
public void authenticate(String targetUser, String authenticatorId, String password) throws IOException { | |
Preconditions.checkState(imapClient.getState() == IMAP.IMAPState.NOT_AUTH_STATE); | |
String loginString = targetUser + "\0" + authenticatorId + "\0" + password; | |
String b64 = Base64.getEncoder().encodeToString(loginString.getBytes(StandardCharsets.UTF_8)); | |
boolean success = imapClient.doCommand(IMAPCommand.AUTHENTICATE, "\"PLAIN\" " + b64 + "\r\n"); | |
if (!success) { | |
throw new IOException("Authentication failed"); | |
} |
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
new jmap.Client(new jmap.RequestTransport()) | |
.withAPIUrl('http://192.168.1.23:44333/jmap') | |
.withAuthenticationToken('d13f3593-3c43-4540-9f83-46342b626696') | |
.listThenGetMessages() | |
.then((response) => { | |
var messages = response[1][1].list; | |
messages.forEach(element => { | |
console.log('email has subject ' + element.subject) | |
}); |
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
listThenGetMessages() { | |
const getMessageListCommandName = '#0'; | |
const body = new BodyBuilder() | |
.appendGetMessageList({}, getMessageListCommandName) | |
.appendGetMessages({ | |
"#ids": { | |
"resultOf": getMessageListCommandName, | |
"name": "getMessageList", | |
"path": "/messageIds" |
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
export default class BodyBuilder { | |
constructor() { | |
this.result = []; | |
} | |
appendGetMessageList(options, name = '#0') { | |
this.append('getMessageList', options, name); | |
return this; | |
} |
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
_jmapRequestWithMultipleCommands(commands) { | |
return this.transport | |
.post(this.apiUrl, this._defaultHeaders(), commands); | |
} |
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
private List<MessageId> resolveMessagesIds(GetMessagesRequest getMessagesRequest, ExecutionContext executionContext) { | |
if (getMessagesRequest.getIdsBackReferencesPath().isPresent()) { | |
BackReferencesPath path = getMessagesRequest.getIdsBackReferencesPath().get(); | |
return executionContext.retreiveBackReferences(path, MessageId.class); | |
} | |
return getMessagesRequest.getIds(); | |
} |
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
@JsonIgnore | |
@Override | |
public <T> List<T> resolve(ResultReferencesPath path, Class<T> clazz) { | |
Preconditions.checkArgument(path.getPath().equals("/messageIds"), "only messageIds is supported"); | |
ResultReferenceTypeMismatchException.assertValidTypes(MessageId.class, clazz); | |
return (List<T>) getMessageIds(); | |
} |
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
@JsonProperty("#ids") | |
public Builder idsBackReference(BackReferencesPath backReferencesPath) { | |
this.idsBackReferencesPath = Optional.of(backReferencesPath); | |
return this; | |
} |
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
[[ "Email/query", { | |
"accountId": "A1", | |
"filter": { "inMailbox": "id_of_inbox" }, | |
"sort": [{ "property": "receivedAt", "isAscending": false }], | |
"collapseThreads": true, | |
"position": 0, | |
"limit": 10, | |
"calculateTotal": true | |
}, "t0" ], | |
[ "Email/get", { |
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
public class ExecutionContext { | |
private final HashMap<ClientId, Method.Response> previousResponses; | |
public void addResponse(ClientId clientId, Method.Response response) { | |
previousResponses.put(clientId, response); | |
} | |
public <T> List<T> retrieveResultReferences(ResultReferencesPath path, Class<T> clazz) { | |
ClientId callId = path.getMethodCallId(); | |
Method.Response response = Optional.ofNullable(previousResponses.get(callId)).get(); |
NewerOlder