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

fix: adjust clip event for helix time truncation #617

Merged
merged 3 commits into from Aug 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,6 +32,7 @@
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -281,9 +282,9 @@ public TwitchClientHelper(TwitchHelix twitchHelix, EventManager eventManager, Sc
followBackoff.get().reset(); // API call was successful

// Prepare EventChannel
String channelName = currentChannelCache.getUserName(); // Prefer login (even if old) to display_name https://github.com/twitchdev/issues/issues/3#issuecomment-562713594
String channelName = currentChannelCache.getUserName();
if (channelName == null && !followList.isEmpty()) {
channelName = followList.get(0).getToName();
channelName = followList.get(0).getToLogin();
currentChannelCache.setUserName(channelName);
}
EventChannel channel = new EventChannel(channelId, channelName);
Expand Down Expand Up @@ -345,7 +346,8 @@ public TwitchClientHelper(TwitchHelix twitchHelix, EventManager eventManager, Sc
nextRequestCanBeImmediate = windowStart.compareAndSet(null, now);
} else {
// get all clips in range [startedAt, now]
final List<Clip> clips = getClips(channelId, startedAt, now);
// end time is adjusted for https://github.com/twitchdev/issues/issues/52
final List<Clip> clips = getClips(channelId, startedAt, now.plus(10, ChronoUnit.MINUTES));

// cache channel name if unknown and construct event channel to be passed to events
if (!clips.isEmpty() && clips.get(0) != null && currentChannelCache.getUserName() == null) {
Expand Down Expand Up @@ -610,7 +612,7 @@ private List<Clip> getClips(String channelId, Instant startedAt, Instant endedAt
},
ClipList::getData,
call -> call.getPagination() != null ? call.getPagination().getCursor() : null,
20
10
);
}

Expand Down