Skip to content

Commit 60cfcbe

Browse files
authored
feat: add live chat translations (#820)
* chat translations wip * upd * upd * upd * upd
1 parent 0b37b8f commit 60cfcbe

File tree

49 files changed

+2278
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2278
-82
lines changed

.github/workflows/dockerv3.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- apps/tokens
3232
- apps/websockets
3333
- apps/ytsr
34+
- apps/chat-translator
3435
- frontend/dashboard
3536
- frontend/overlays
3637
steps:

apps/api-gql/cmd/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/twirapp/twir/apps/api-gql/internal/services/channels"
2626
"github.com/twirapp/twir/apps/api-gql/internal/services/channels_commands_prefix"
2727
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_messages"
28+
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_translation"
2829
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_wall"
2930
"github.com/twirapp/twir/apps/api-gql/internal/services/commands"
3031
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_groups"
@@ -111,6 +112,9 @@ import (
111112
chatwallrepository "github.com/twirapp/twir/libs/repositories/chat_wall"
112113
chatwallpostgres "github.com/twirapp/twir/libs/repositories/chat_wall/datasource/postgres"
113114

115+
chattranslationrepository "github.com/twirapp/twir/libs/repositories/chat_translation"
116+
chattranslationpostgres "github.com/twirapp/twir/libs/repositories/chat_translation/datasource/postgres"
117+
114118
channelscommandsprefixrepository "github.com/twirapp/twir/libs/repositories/channels_commands_prefix"
115119
channelscommandsprefixpgx "github.com/twirapp/twir/libs/repositories/channels_commands_prefix/pgx"
116120
"go.uber.org/fx"
@@ -221,6 +225,10 @@ func main() {
221225
chatwallpostgres.NewFx,
222226
fx.As(new(chatwallrepository.Repository)),
223227
),
228+
fx.Annotate(
229+
chattranslationpostgres.NewFx,
230+
fx.As(new(chattranslationrepository.Repository)),
231+
),
224232
),
225233
// services
226234
fx.Provide(
@@ -257,6 +265,7 @@ func main() {
257265
spotify_integration.New,
258266
scheduled_vips.New,
259267
chat_wall.New,
268+
chat_translation.New,
260269
),
261270
// grpc clients
262271
fx.Provide(

apps/api-gql/internal/delivery/gql/mappers/audit-logs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ var tableToGqlModel = map[string]gqlmodel.AuditLogSystem{
6767
"channels_integrations": gqlmodel.AuditLogSystemChannelIntegrations,
6868
"channels_alerts": gqlmodel.AuditLogSystemChannelsAlerts,
6969
"channels_chat_alerts": gqlmodel.AuditLogSystemChannelsChatAlerts,
70+
"channels_chat_translation": gqlmodel.AuditLogSystemChannelsChatTranslation,
7071
}
7172

7273
func AuditTableNameToGqlSystem(t string) gqlmodel.AuditLogSystem {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 ChatTranslationEntityTo(e entity.ChatTranslation) gqlmodel.ChatTranslation {
9+
return gqlmodel.ChatTranslation{
10+
ID: e.ID.String(),
11+
ChannelID: e.ChannelID,
12+
Enabled: e.Enabled,
13+
TargetLanguage: e.TargetLanguage,
14+
ExcludedLanguages: e.ExcludedLanguages,
15+
UseItalic: e.UseItalic,
16+
ExcludedUsersIDs: e.ExcludedUsersIDs,
17+
CreatedAt: e.CreatedAt,
18+
UpdatedAt: e.UpdatedAt,
19+
}
20+
}

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

Lines changed: 148 additions & 0 deletions
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/moderation.resolver.go

Lines changed: 2 additions & 5 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
badges_users "github.com/twirapp/twir/apps/api-gql/internal/services/badges-users"
1919
"github.com/twirapp/twir/apps/api-gql/internal/services/channels_commands_prefix"
2020
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_messages"
21+
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_translation"
2122
"github.com/twirapp/twir/apps/api-gql/internal/services/chat_wall"
2223
"github.com/twirapp/twir/apps/api-gql/internal/services/commands"
2324
"github.com/twirapp/twir/apps/api-gql/internal/services/commands_responses"
@@ -102,6 +103,7 @@ type Deps struct {
102103
SevenTvIntegrationService *seventv_integration.Service
103104
SpotifyIntegrationService *spotify_integration.Service
104105
ScheduledVipsService *scheduled_vips.Service
106+
ChatTranslationService *chat_translation.Service
105107
ChatWallService *chat_wall.Service
106108
Config config.Config
107109
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
extend type Query {
2+
chatTranslation: ChatTranslation @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: VIEW_MODULES)
3+
}
4+
5+
extend type Mutation {
6+
chatTranslationCreate(input: ChatTranslationCreateInput!): ChatTranslation! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_MODULES)
7+
chatTranslationUpdate(id: String!, input: ChatTranslationUpdateInput!): ChatTranslation! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_MODULES)
8+
chatTranslationDelete(id: String!): Boolean! @isAuthenticated @hasAccessToSelectedDashboard @hasChannelRolesDashboardPermission(permission: MANAGE_MODULES)
9+
}
10+
11+
type ChatTranslation {
12+
id: String!
13+
channelID: String!
14+
enabled: Boolean!
15+
targetLanguage: String!
16+
excludedLanguages: [String!]!
17+
useItalic: Boolean!
18+
excludedUsersIDs: [String!]!
19+
createdAt: Time!
20+
updatedAt: Time!
21+
}
22+
23+
input ChatTranslationCreateInput {
24+
enabled: Boolean!
25+
targetLanguage: String!
26+
excludedLanguages: [String!]!
27+
useItalic: Boolean!
28+
excludedUsersIDs: [String!]!
29+
}
30+
31+
input ChatTranslationUpdateInput {
32+
enabled: Boolean
33+
targetLanguage: String
34+
excludedLanguages: [String!]
35+
useItalic: Boolean
36+
excludedUsersIDs: [String!]
37+
}

apps/api-gql/internal/delivery/gql/schema/roles.graphqls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ enum ChannelRolePermissionEnum {
8383

8484
VIEW_BOT_SETTINGS
8585
MANAGE_BOT_SETTINGS
86+
87+
VIEW_MODULES
88+
MANAGE_MODULES
8689
}
8790

8891
directive @hasChannelRolesDashboardPermission(permission: ChannelRolePermissionEnum) on FIELD_DEFINITION

apps/api-gql/internal/delivery/gql/schema/user-audit-logs.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ enum AuditLogSystem {
4343
CHANNELS_ALERTS
4444
CHANNELS_MODULES_SETTINGS
4545
CHANNELS_CHAT_ALERTS
46+
CHANNELS_CHAT_TRANSLATION
4647
}

0 commit comments

Comments
 (0)