Skip to content

Commit ace3c6c

Browse files
committed
refactor: use gql for 7tv integration
1 parent 3be5fc3 commit ace3c6c

File tree

40 files changed

+1453
-516
lines changed

40 files changed

+1453
-516
lines changed

apps/api-gql/cmd/main.go

+16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/twirapp/twir/apps/api-gql/internal/services/roles"
3939
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
4040
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
41+
"github.com/twirapp/twir/apps/api-gql/internal/services/seventv_integration"
4142
"github.com/twirapp/twir/apps/api-gql/internal/services/song_requests"
4243
"github.com/twirapp/twir/apps/api-gql/internal/services/streamelements"
4344
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
@@ -92,6 +93,12 @@ import (
9293
variablesrepository "github.com/twirapp/twir/libs/repositories/variables"
9394
variablespgx "github.com/twirapp/twir/libs/repositories/variables/pgx"
9495

96+
seventvintegrationrepository "github.com/twirapp/twir/libs/repositories/seventv_integration"
97+
seventvintegrationpostgres "github.com/twirapp/twir/libs/repositories/seventv_integration/datasource/postgres"
98+
99+
botsrepository "github.com/twirapp/twir/libs/repositories/bots"
100+
botspostgres "github.com/twirapp/twir/libs/repositories/bots/datasource/postgres"
101+
95102
channelscommandsprefixrepository "github.com/twirapp/twir/libs/repositories/channels_commands_prefix"
96103
channelscommandsprefixpgx "github.com/twirapp/twir/libs/repositories/channels_commands_prefix/pgx"
97104
"go.uber.org/fx"
@@ -182,6 +189,14 @@ func main() {
182189
channelsintegrationsspotifypgx.NewFx,
183190
fx.As(new(channelsintegrationsspotify.Repository)),
184191
),
192+
fx.Annotate(
193+
seventvintegrationpostgres.NewFx,
194+
fx.As(new(seventvintegrationrepository.Repository)),
195+
),
196+
fx.Annotate(
197+
botspostgres.NewFx,
198+
fx.As(new(botsrepository.Repository)),
199+
),
185200
),
186201
// services
187202
fx.Provide(
@@ -214,6 +229,7 @@ func main() {
214229
community_redemptions.New,
215230
streamelements.New,
216231
dashboard.New,
232+
seventv_integration.New,
217233
),
218234
// grpc clients
219235
fx.Provide(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package mappers
2+
3+
import (
4+
"github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/gqlmodel"
5+
"github.com/twirapp/twir/apps/api-gql/internal/entity"
6+
)
7+
8+
func MapSevenTvIntegrationDataToGql(
9+
data entity.SevenTvIntegrationData,
10+
) *gqlmodel.SevenTvIntegration {
11+
return &gqlmodel.SevenTvIntegration{
12+
IsEditor: data.IsEditor,
13+
BotSeventvProfile: MapSevenTvProfileToGql(data.BotSeventvProfile),
14+
UserSeventvProfile: MapSevenTvProfileToGql(data.UserSeventvProfile),
15+
RewardIDForAddEmote: data.RewardIDForAddEmote,
16+
RewardIDForRemoveEmote: data.RewardIDForRemoveEmote,
17+
EmoteSetID: data.EmoteSetID,
18+
DeleteEmotesOnlyAddedByApp: data.DeleteEmotesOnlyAddedByApp,
19+
}
20+
}
21+
22+
func MapSevenTvProfileToGql(profile *entity.SevenTvProfile) *gqlmodel.SevenTvProfile {
23+
return &gqlmodel.SevenTvProfile{
24+
ID: profile.ID,
25+
Username: profile.Username,
26+
DisplayName: profile.DisplayName,
27+
AvatarURI: profile.AvatarURI,
28+
}
29+
}

apps/api-gql/internal/delivery/gql/resolvers/integration-seventv.resolver.go

+73
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/api-gql/internal/delivery/gql/resolvers/resolver.go

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/twirapp/twir/apps/api-gql/internal/services/roles"
3131
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
3232
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
33+
"github.com/twirapp/twir/apps/api-gql/internal/services/seventv_integration"
3334
"github.com/twirapp/twir/apps/api-gql/internal/services/song_requests"
3435
"github.com/twirapp/twir/apps/api-gql/internal/services/streamelements"
3536
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
@@ -95,6 +96,7 @@ type Deps struct {
9596
CommunityRedemptionsService *community_redemptions.Service
9697
StreamElementsService *streamelements.Service
9798
DashboardService *dashboard.Service
99+
SevenTvIntegrationService *seventv_integration.Service
98100
Config config.Config
99101
}
100102

apps/api-gql/internal/delivery/gql/resolvers/rewards.resolver.go

+1-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
extend type Subscription {
2+
sevenTvData: SevenTvIntegration! @isAuthenticated
3+
}
4+
5+
extend type Mutation {
6+
sevenTvUpdate(input: SevenTvUpdateInput!): Boolean! @isAuthenticated
7+
}
8+
9+
type SevenTvProfile {
10+
id: String!
11+
username: String!
12+
displayName: String!
13+
avatarUri: String!
14+
}
15+
16+
type SevenTvIntegration {
17+
isEditor: Boolean!
18+
botSeventvProfile: SevenTvProfile!
19+
userSeventvProfile: SevenTvProfile!
20+
rewardIdForAddEmote: String
21+
rewardIdForRemoveEmote: String
22+
emoteSetId: String
23+
deleteEmotesOnlyAddedByApp: Boolean!
24+
}
25+
26+
input SevenTvUpdateInput {
27+
rewardIdForAddEmote: String
28+
rewardIdForRemoveEmote: String
29+
deleteEmotesOnlyAddedByApp: Boolean!
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package entity
2+
3+
type SevenTvIntegrationData struct {
4+
IsEditor bool
5+
BotSeventvProfile *SevenTvProfile
6+
UserSeventvProfile *SevenTvProfile
7+
RewardIDForAddEmote *string
8+
RewardIDForRemoveEmote *string
9+
EmoteSetID *string
10+
DeleteEmotesOnlyAddedByApp bool
11+
}
12+
13+
type SevenTvProfile struct {
14+
ID string
15+
Username string
16+
DisplayName string
17+
Editors []SevenTvProfileEditor
18+
EmoteSetID *string
19+
AvatarURI string
20+
}
21+
22+
type SevenTvProfileEditor struct {
23+
ID string
24+
Permissions int
25+
Visible bool
26+
AddedAt int64
27+
}

0 commit comments

Comments
 (0)