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

Added handling for relationship presence updates #494

Merged
merged 8 commits into from
Oct 25, 2017

Conversation

MinnDevelopment
Copy link
Member

No description provided.

? Game.GameType.DEFAULT
: Game.GameType.fromKey(Integer.parseInt(content.getJSONObject("game").get("type").toString()));
: Game.GameType.fromKey(Integer.parseInt(game.get("type").toString()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't game.getInt("type") be the same here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past we've encountered numerous issues with game objects due to them not being checked by the API, I didn't touch that logic at all here.

if (friend == null)
{
if (status != OnlineStatus.OFFLINE)
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, looks like I forgot to remove this after I decided not to cache these presence updates

if (content.has("guild_id"))
{
GuildImpl guild = (GuildImpl) api.getGuildById(content.getLong("guild_id"));
if (guild != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the //cache in relationship stuff isn't correct here.
We need to be caching this presence for a very soon Group add, similar to how we are doing for the Guild presence caching.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced we should be caching relationship presence updates, groups don't send these.

@MinnDevelopment
Copy link
Member Author

@DV8FromTheWorld can I get an update on your view on this PR?

api.getEventManager().handle(
new UserGameUpdateEvent(
api, responseNumber,
user, null, oldGame));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be firing FriendXEvents, not UserXEvents I think.
In that same vain though, we probably should rename the User events to Member events?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, at a minimum, take a Friend object to these User events so that you can call getFriend like you can call getMember.

Copy link
Member Author

@MinnDevelopment MinnDevelopment Oct 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MinnDevelopment MinnDevelopment modified the milestones: Upcoming Release, Release 3.4 Oct 21, 2017
…date

# Conflicts:
#	src/main/java/net/dv8tion/jda/core/requests/WebSocketClient.java
@@ -208,11 +208,9 @@ protected Long handleInternally(JSONObject content)

//If the OnlineStatus is OFFLINE, ignore the event and return.
OnlineStatus status = OnlineStatus.fromKey(content.getString("status"));
if (status == OnlineStatus.OFFLINE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lost the ability to return in an OFFLINE non-guild situation.
Is that correct handling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate? Not sure what you mean

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I see what has changed here. The fast escape logic is no longer needed.

@@ -1319,8 +1321,11 @@ private void setupHandlers()
handlers.put("VOICE_STATE_UPDATE", new VoiceStateUpdateHandler(api));

// Unused events
handlers.put("CHANNEL_PINS_UPDATE", new SocketHandler.NOPHandler(api));
handlers.put("WEBHOOKS_UPDATE", new SocketHandler.NOPHandler(api));
final SocketHandler.NOPHandler nopHandler = new SocketHandler.NOPHandler(api);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, since NOPHandler will never be implemented, we should have it be a public static final instance in SocketHandler instead of in-line creating one here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that the SocketHandler constructor expects a JDA instance and I don't want to add confusing situations where that JDA instance isn't present/null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I can get behind that.
However, lets create the final variable at the top of the method, not in the middle.

@MinnDevelopment MinnDevelopment added the status: completed has been completed but is not yet released label Oct 25, 2017
@MinnDevelopment MinnDevelopment merged commit b436c3e into master Oct 25, 2017
@MinnDevelopment MinnDevelopment deleted the feature/presence-updates branch October 25, 2017 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status: completed has been completed but is not yet released type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants