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

2.2.10 #625

Merged
merged 8 commits into from
Oct 23, 2023
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ updates:
timezone: "Europe/Paris"
pull-request-branch-name:
separator: "-"
groups:
log4j:
patterns:
- "org.apache.logging.log4j:log4j-core"
- "org.apache.logging.log4j:log4j-slf4j2-impl"
# Disable while paths can't be ignored as it'd update all 'auto-approve-sync-files.yml', Renovate will handle exclusion
# - package-ecosystem: "github-actions"
# directory: "/"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.2.9
version=2.2.10
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
slf4j-version = "2.0.9"
log4j2-version = "2.20.0"
log4j2-slf4j-version = "2.20.0"
log4j2-version = "2.21.0"
log4j2-slf4j-version = "2.21.0"
unirest-version = "4.1.0"
picocli-version = "4.7.5"
jackson-version = "2.15.3"
Expand All @@ -20,19 +20,19 @@ json-unit-version = "3.2.2"
kitteh-irc-version = "8.0.0"
hikari-cp-version = "5.0.1"
mariadb-version = "3.2.0"
sqlite-version = "3.43.2.0"
sqlite-version = "3.43.2.1"
mysql-version = "8.1.0"
rerunner-jupiter-version = "2.1.6"
flyway-version = "9.22.3"
selenide-version = "6.19.0"
selenide-version = "6.19.1"
lombok-version = "1.18.30"
jacocoVersion = "0.8.10"

shadow-version = "8.1.1"
names-version = "0.49.0"
jib-version = "3.4.0"
git-properties-version = "2.4.1"
springboot-version = "3.1.4"
springboot-version = "3.1.5"
springboot-dependencies-version = "1.1.3"
test-logger-version = "4.0.0"
git-version-plugin-version = "3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,26 @@
@Builder
@EqualsAndHashCode
public class MinuteWatchedProperties{
@JsonProperty("channel_id")
@NotNull
private String channelId;
@JsonProperty("broadcast_id")
@NotNull
private String broadcastId;
@JsonProperty("channel")
@NotNull
private String channel;
@JsonProperty("channel_id")
@NotNull
private String channelId;
@JsonProperty("game")
@Nullable
private String game;
@JsonProperty("game_id")
@Nullable
private String gameId;
@JsonProperty("live")
private boolean live;
@JsonProperty("player")
@NotNull
private String player;
@JsonProperty("user_id")
private int userId;
@JsonProperty("game")
@Nullable
private String game;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import fr.rakambda.channelpointsminer.miner.util.json.ISO8601ZonedDateTimeDeserializer;
import fr.rakambda.channelpointsminer.miner.util.json.UnknownDeserializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand All @@ -29,4 +30,8 @@ public class Summary{
@JsonDeserialize(using = ISO8601ZonedDateTimeDeserializer.class)
@Nullable
private ZonedDateTime lastSeen;
@JsonProperty("count_by_md")
@Nullable
@JsonDeserialize(using = UnknownDeserializer.class)
private Object countByMd;
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ public void start(){
scheduledExecutor.schedule(streamerConfigurationReload, 0, MINUTES);
}

listenTopic(COMMUNITY_POINTS_USER_V1, getTwitchLogin().fetchUserId(gqlApi));
listenTopic(USER_DROP_EVENTS, getTwitchLogin().fetchUserId(gqlApi));
listenTopic(ONSITE_NOTIFICATIONS, getTwitchLogin().fetchUserId(gqlApi));
var connectedUserId = getTwitchLogin().fetchUserId(gqlApi);
listenTopic(COMMUNITY_POINTS_USER_V1, connectedUserId);
listenTopic(USER_DROP_EVENTS, connectedUserId);
listenTopic(ONSITE_NOTIFICATIONS, connectedUserId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ private boolean send(Streamer streamer){
var request = MinuteWatchedEvent.builder()
.properties(MinuteWatchedProperties.builder()
.channelId(streamer.getId())
.channel(streamer.getUsername())
.broadcastId(streamId.get())
.player(SITE_PLAYER)
.userId(miner.getTwitchLogin().getUserIdAsInt(miner.getGqlApi()))
.gameId(streamer.getGame().map(Game::getId).orElse(null))
.game(streamer.getGame().map(Game::getName).orElse(null))
.live(true)
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String deserialize(@NotNull JsonParser jsonParser, @NotNull Deserializati
var currentLocation = jsonParser.getCurrentLocation();
var treeNode = jsonParser.readValueAsTree();
var treeNodeStr = treeNode == null ? null : treeNode.toString();
log.warn("Got actual value for field {} (l:{},c:{}) : {}", jsonParser.getCurrentName(), currentLocation.getLineNr(), currentLocation.getColumnNr(), treeNodeStr);
log.warn("Got actual value for unknown field {} (l:{},c:{}) : {}", jsonParser.getCurrentName(), currentLocation.getLineNr(), currentLocation.getColumnNr(), treeNodeStr);
return treeNodeStr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class TwitchApiTest{
private static final int USER_ID = 123456789;
private static final String BROADCAST_ID = "broadcast-id";
private static final String CHANNEL_ID = "channel-id";
private static final String CHANNEL_NAME = "channel-name";
private static final String PLAYER = "player";
private static final String GAME = "game";
private static final String GAME_ID = "game-id";
private static final String STREAMER_URL = "https://google.com/streamer";
private static final String CONFIG_URL = "https://static.twitchcdn.net/config/settings.sq5d4q6s54ds854c84qs.js";
private static final String CONFIG_BODY = "<script src=\"%s\" crossorigin=\"anonymous\"></script>".formatted(CONFIG_URL);
Expand All @@ -56,8 +58,8 @@ void setUp(UnirestMock unirestMock) throws MalformedURLException{

@Test
void sendMinutesWatched(UnirestMock unirest){
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel_id\":\"%s\",\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_ID, PLAYER, USER_ID);
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel\":\"%s\",\"channel_id\":\"%s\",\"live\":true,\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_NAME, CHANNEL_ID, PLAYER, USER_ID);
var expectedData = new String(Base64.getEncoder().encode(json.getBytes(UTF_8)));

unirest.expect(POST, SPADE_URL)
Expand All @@ -70,7 +72,9 @@ void sendMinutesWatched(UnirestMock unirest){
.userId(USER_ID)
.broadcastId(BROADCAST_ID)
.channelId(CHANNEL_ID)
.channel(CHANNEL_NAME)
.player(PLAYER)
.live(true)
.build())
.build();
assertThat(tested.sendPlayerEvents(spadeUrl, request)).isTrue();
Expand All @@ -80,8 +84,8 @@ void sendMinutesWatched(UnirestMock unirest){

@Test
void sendMinutesWatchedWithGame(UnirestMock unirest){
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel_id\":\"%s\",\"game\":\"%s\",\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_ID, GAME, PLAYER, USER_ID);
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel\":\"%s\",\"channel_id\":\"%s\",\"game\":\"%s\",\"game_id\":\"%s\",\"live\":true,\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_NAME, CHANNEL_ID, GAME, GAME_ID, PLAYER, USER_ID);
var expectedData = new String(Base64.getEncoder().encode(json.getBytes(UTF_8)));

unirest.expect(POST, SPADE_URL)
Expand All @@ -93,9 +97,12 @@ void sendMinutesWatchedWithGame(UnirestMock unirest){
.properties(MinuteWatchedProperties.builder()
.userId(USER_ID)
.broadcastId(BROADCAST_ID)
.channelId(CHANNEL_ID)
.player(PLAYER)
.channelId(CHANNEL_ID)
.channel(CHANNEL_NAME)
.player(PLAYER)
.game(GAME)
.gameId(GAME_ID)
.live(true)
.build())
.build();
assertThat(tested.sendPlayerEvents(spadeUrl, request)).isTrue();
Expand All @@ -105,8 +112,8 @@ void sendMinutesWatchedWithGame(UnirestMock unirest){

@Test
void sendMinutesWatchedNotSuccess(UnirestMock unirest){
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel_id\":\"%s\",\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_ID, PLAYER, USER_ID);
var json = "[{\"event\":\"minute-watched\",\"properties\":{\"broadcast_id\":\"%s\",\"channel\":\"%s\",\"channel_id\":\"%s\",\"live\":true,\"player\":\"%s\",\"user_id\":%d}}]"
.formatted(BROADCAST_ID, CHANNEL_NAME, CHANNEL_ID, PLAYER, USER_ID);
var expectedData = new String(Base64.getEncoder().encode(json.getBytes(UTF_8)));

unirest.expect(POST, SPADE_URL)
Expand All @@ -119,7 +126,9 @@ void sendMinutesWatchedNotSuccess(UnirestMock unirest){
.userId(USER_ID)
.broadcastId(BROADCAST_ID)
.channelId(CHANNEL_ID)
.channel(CHANNEL_NAME)
.player(PLAYER)
.live(true)
.build())
.build();
assertThat(tested.sendPlayerEvents(spadeUrl, request)).isFalse();
Expand All @@ -139,7 +148,9 @@ void sendMinutesWatchedJsonError(){
.userId(USER_ID)
.broadcastId(BROADCAST_ID)
.channelId(CHANNEL_ID)
.channel(CHANNEL_NAME)
.player(PLAYER)
.live(true)
.build())
.build();
assertThat(tested.sendPlayerEvents(spadeUrl, request)).isFalse();
Expand Down
Loading
Loading