Skip to content

Commit f8713c0

Browse files
committed
[Bug Fix] reply was added as a staff reply in Zendesk
1 parent d4793fd commit f8713c0

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

helpstack/src/com/tenmiles/helpstack/gears/HSZendeskGear.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public void onResponse(JSONObject response) {
377377
}
378378
}, errorListener);
379379

380-
request.addCredential(staff_email_address, api_token);
380+
request.addCredential(user.getEmail(), api_token);
381381
request.setTag(cancelTag);
382382
request.setRetryPolicy(new DefaultRetryPolicy(ZendeskJsonObjectRequest.TIMEOUT_MS,
383383
ZendeskJsonObjectRequest.MAX_RETRIES, ZendeskJsonObjectRequest.BACKOFF_MULT));
@@ -462,7 +462,7 @@ private HSTicketUpdate retrieveTicketUpdate(JSONObject updateObject, JSONArray u
462462
JSONArray eventsArray = updateObject.getJSONArray("events");
463463

464464
int eventsArrayLength = eventsArray.length();
465-
for (int i = 0; i < eventsArrayLength; i++) {
465+
for (int i = 0; i < eventsArrayLength; i++) { //else Nothing
466466
JSONObject eventObject = eventsArray.getJSONObject(i);
467467
if (eventObject.getString("type").equals("Comment")) {
468468

@@ -480,19 +480,23 @@ private HSTicketUpdate retrieveTicketUpdate(JSONObject updateObject, JSONArray u
480480
// authorId can be null here because of previous if loop. Make sure to handle it properly
481481
JSONObject author = searchForUser(authorId, usersArray);
482482

483-
if (!author.isNull("name")) {
484-
from = author.getString("name");
483+
if (author != null) {
484+
if (!author.isNull("name")) {
485+
from = author.getString("name");
486+
}
487+
488+
String role = author.getString("role");
489+
if (role.equals("end-user")) {
490+
isUpdateTypeUserReply = true;
491+
}
485492
}
493+
494+
486495

487496
if (!updateObject.isNull("created_at")) {
488497
update_time = parseTime(updateObject.getString("created_at"));
489498
}
490499

491-
String role = author.getString("role");
492-
if (role.equals("end-user")) {
493-
isUpdateTypeUserReply = true;
494-
}
495-
496500
JSONArray attachmentObjects = eventObject.getJSONArray("attachments");
497501
if(attachmentObjects != null) {
498502
int length = attachmentObjects.length();
@@ -508,6 +512,9 @@ private HSTicketUpdate retrieveTicketUpdate(JSONObject updateObject, JSONArray u
508512
}
509513
attachments = attachmentArray.toArray(new HSAttachment[length]);
510514
}
515+
516+
517+
break;
511518
}
512519
}
513520

@@ -562,7 +569,7 @@ private JSONObject searchForUser(int userId, JSONArray usersArray) throws JSONEx
562569
}
563570
}
564571

565-
return usersObject;
572+
return null;
566573
}
567574

568575
private void showArticlesInSection(String cancelTag, String section_id, RequestQueue queue, final OnFetchedArraySuccessListener successListener, final ErrorListener errorListener) {

0 commit comments

Comments
 (0)