feat: update status display type based on activity name configuration
This commit is contained in:
@@ -152,6 +152,7 @@ func (p *discordPlugin) NowPlaying(input scrobbler.NowPlayingRequest) error {
|
||||
|
||||
// Resolve the activity name based on configuration
|
||||
activityName := "Navidrome"
|
||||
statusDisplayType := 0
|
||||
activityNameOption, _ := pdk.GetConfig(activityNameKey)
|
||||
switch activityNameOption {
|
||||
case activityNameTrack:
|
||||
@@ -160,6 +161,8 @@ func (p *discordPlugin) NowPlaying(input scrobbler.NowPlayingRequest) error {
|
||||
activityName = input.Track.Album
|
||||
case activityNameArtist:
|
||||
activityName = input.Track.Artist
|
||||
default:
|
||||
statusDisplayType = 2
|
||||
}
|
||||
|
||||
// Resolve Spotify URLs if enabled
|
||||
@@ -179,7 +182,7 @@ func (p *discordPlugin) NowPlaying(input scrobbler.NowPlayingRequest) error {
|
||||
DetailsURL: spotifyURL,
|
||||
State: input.Track.Artist,
|
||||
StateURL: artistSearchURL,
|
||||
StatusDisplayType: 2,
|
||||
StatusDisplayType: statusDisplayType,
|
||||
Timestamps: activityTimestamps{
|
||||
Start: startTime,
|
||||
End: endTime,
|
||||
|
||||
+7
-6
@@ -170,7 +170,7 @@ var _ = Describe("discordPlugin", func() {
|
||||
})
|
||||
|
||||
DescribeTable("activity name configuration",
|
||||
func(configValue string, configExists bool, expectedName string) {
|
||||
func(configValue string, configExists bool, expectedName string, expectedDisplayType int) {
|
||||
pdk.PDKMock.On("GetConfig", clientIDKey).Return("test-client-id", true)
|
||||
pdk.PDKMock.On("GetConfig", usersKey).Return(`[{"username":"testuser","token":"test-token"}]`, true)
|
||||
pdk.PDKMock.On("GetConfig", uguuEnabledKey).Return("", false)
|
||||
@@ -217,12 +217,13 @@ var _ = Describe("discordPlugin", func() {
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(sentPayload).To(ContainSubstring(fmt.Sprintf(`"name":"%s"`, expectedName)))
|
||||
Expect(sentPayload).To(ContainSubstring(fmt.Sprintf(`"status_display_type":%d`, expectedDisplayType)))
|
||||
},
|
||||
Entry("defaults to Navidrome when not configured", "", false, "Navidrome"),
|
||||
Entry("defaults to Navidrome with explicit default value", "Default", true, "Navidrome"),
|
||||
Entry("uses track title when configured", "Track", true, "Test Song"),
|
||||
Entry("uses track album when configured", "Album", true, "Test Album"),
|
||||
Entry("uses track artist when configured", "Artist", true, "Test Artist"),
|
||||
Entry("defaults to Navidrome when not configured", "", false, "Navidrome", 2),
|
||||
Entry("defaults to Navidrome with explicit default value", "Default", true, "Navidrome", 2),
|
||||
Entry("uses track title when configured", "Track", true, "Test Song", 0),
|
||||
Entry("uses track album when configured", "Album", true, "Test Album", 0),
|
||||
Entry("uses track artist when configured", "Artist", true, "Test Artist", 0),
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user