Skip to content
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

find bugs updates #234

Merged
merged 3 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
import java.util.Objects;

public class SlackPreparedMessage {

private String message;
private boolean unfurl;
private boolean linkNames;
private SlackAttachment[] attachments;
private List<SlackAttachment> attachments;
private String threadTimestamp;
private boolean replyBroadcast;


private SlackPreparedMessage(String message, boolean unfurl, boolean linkNames, SlackAttachment[] attachments, String threadTimestamp, boolean replyBroadcast) {
this.message = message;
this.unfurl = unfurl;
this.linkNames = linkNames;
this.attachments = attachments;
this.attachments = Arrays.asList(attachments);
this.threadTimestamp = threadTimestamp;
this.replyBroadcast = replyBroadcast;
}
Expand All @@ -40,7 +42,7 @@ public boolean isLinkNames() {
}

public SlackAttachment[] getAttachments() {
return attachments;
return attachments.toArray(new SlackAttachment[]{});
}

public String getThreadTimestamp() {
Expand Down Expand Up @@ -125,7 +127,7 @@ public String toString() {
return "SlackPreparedMessage{" +
"message='" + message + '\'' +
", unfurl=" + unfurl +
", attachments=" + Arrays.toString(attachments) +
", attachments=" + attachments +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public List<SlackMessagePosted> fetchUpdatingHistoryOfChannel(String channelId,
return messages;
}

public class ChannelHistoryReactionAddedListener implements ReactionAddedListener {
public static class ChannelHistoryReactionAddedListener implements ReactionAddedListener {

List<SlackMessagePosted> messages = new ArrayList<>();

Expand All @@ -174,7 +174,7 @@ public void onEvent(ReactionAdded event, SlackSession session) {
for (String reaction : message.getReactions().keySet()) {
if (emojiName.equals(reaction)) {
int count = message.getReactions().get(emojiName);
message.getReactions().put(emojiName, count++);
message.getReactions().put(emojiName, ++count);
return;
}
}
Expand All @@ -183,7 +183,7 @@ public void onEvent(ReactionAdded event, SlackSession session) {
}
};

public class ChannelHistoryReactionRemovedListener implements ReactionRemovedListener {
public static class ChannelHistoryReactionRemovedListener implements ReactionRemovedListener {

List<SlackMessagePosted> messages = new ArrayList<>();

Expand All @@ -210,7 +210,7 @@ public void onEvent(ReactionRemoved event, SlackSession session) {
}
}

public class ChannelHistoryMessagePostedListener implements SlackMessagePostedListener {
public static class ChannelHistoryMessagePostedListener implements SlackMessagePostedListener {

List<SlackMessagePosted> messages = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class SlackJSONMessageParser {
private static final Logger LOGGER = LoggerFactory.getLogger(SlackJSONMessageParser.class);

public static enum SlackMessageSubType
{
Expand Down Expand Up @@ -270,6 +274,7 @@ private static void parseSlackFileFromRaw(JsonObject rawFile, SlackFile file) {
file.setImageExifRotation(GsonHelper.getLongOrNull(rawFile.get("image_exif_rotation")));
} catch(Exception e){
//this properties will be null if something goes wrong
LOGGER.error("Failed to parse slack file", e);
}
file.setPermalink(GsonHelper.getStringOrNull(rawFile.get("permalink")));
file.setPermalinkPublic(GsonHelper.getStringOrNull(rawFile.get("permalink_public")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static final SlackUser buildSlackUser(JsonObject jsonUser)
{
slackPresence = SlackPersona.SlackPresence.AWAY;
}
return new SlackUserImpl(id, name, realName, email, skype, title, phone, deleted, admin, owner, primaryOwner, restricted, ultraRestricted, bot, tz, tzLabel, tzOffset == null ? null : new Integer(tzOffset.intValue()), slackPresence);
return new SlackUserImpl(id, name, realName, email, skype, title, phone, deleted, admin, owner, primaryOwner, restricted, ultraRestricted, bot, tz, tzLabel, tzOffset, slackPresence);
}

static final SlackChannel buildSlackChannel(JsonObject jsonChannel, Map<String, SlackUser> knownUsersById) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.net.ConnectException;
import java.net.Proxy;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -234,7 +235,7 @@ void dispatch(SlackEvent event) {
case USER_TYPING:
dispatchImpl((UserTyping) event, userTypingListener);
break;
case UNKNOWN:
default:
LOGGER.warn("event of type " + event.getEventType() + " not handled: " + ((UnknownEvent)event).getJsonPayload());
}
}
Expand Down Expand Up @@ -867,7 +868,7 @@ private void postSlackCommandWithFile(Map<String, String> params, byte [] fileCo
builder.addBinaryBody("file",fileContent, ContentType.DEFAULT_BINARY,fileName);
request.setEntity(builder.build());
HttpResponse response = client.execute(request);
String jsonResponse = ReaderUtils.readAll(new InputStreamReader(response.getEntity().getContent()));
String jsonResponse = ReaderUtils.readAll(new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")));
LOGGER.debug("PostMessage return: " + jsonResponse);
ParsedSlackReply reply = SlackJSONReplyParser.decode(parseObject(jsonResponse),this);
handle.setReply(reply);
Expand Down