mirror of
https://github.com/wassname/talk.git
synced 2026-08-02 13:10:23 +08:00
[CORL-1219] Media Type Fixes (#3051)
* fix: better graphql types * fix: fixed tests * fix: fixed tests
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import {
|
||||
GQLGiphyMediaConfiguration,
|
||||
GQLGiphyMediaConfigurationTypeResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const GiphyMediaConfiguration: GQLGiphyMediaConfigurationTypeResolver<Partial<
|
||||
GQLGiphyMediaConfiguration
|
||||
>> = {
|
||||
enabled: ({ enabled = false }) => enabled,
|
||||
maxRating: ({ maxRating = "g" }) => maxRating,
|
||||
};
|
||||
@@ -3,8 +3,10 @@ import {
|
||||
GQLMediaConfigurationTypeResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const MediaConfiguration: GQLMediaConfigurationTypeResolver<GQLMediaConfiguration> = {
|
||||
twitter: ({ twitter }) => (twitter ? twitter : false),
|
||||
youtube: ({ youtube }) => (youtube ? youtube : false),
|
||||
giphy: ({ giphy }) => (giphy ? giphy : false),
|
||||
export const MediaConfiguration: GQLMediaConfigurationTypeResolver<Partial<
|
||||
GQLMediaConfiguration
|
||||
>> = {
|
||||
twitter: ({ twitter = {} }) => twitter,
|
||||
youtube: ({ youtube = {} }) => youtube,
|
||||
giphy: ({ giphy = {} }) => giphy,
|
||||
};
|
||||
|
||||
@@ -31,19 +31,5 @@ export const Settings: GQLSettingsTypeResolver<Tenant> = {
|
||||
},
|
||||
webhookEvents: () => Object.values(GQLWEBHOOK_EVENT_NAME),
|
||||
rte: ({ rte = defaultRTEConfiguration }) => rte,
|
||||
media: ({ media }) => {
|
||||
if (!media) {
|
||||
return {
|
||||
twitter: { enabled: false },
|
||||
youtube: { enabled: false },
|
||||
giphy: { enabled: false },
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
twitter: media.twitter || { enabled: false },
|
||||
youtube: media.youtube || { enabled: false },
|
||||
giphy: media.giphy || { enabled: false, maxRating: "g" },
|
||||
};
|
||||
},
|
||||
media: ({ media = {} }) => media,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
GQLTwitterMediaConfiguration,
|
||||
GQLTwitterMediaConfigurationTypeResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const TwitterMediaConfiguration: Required<GQLTwitterMediaConfigurationTypeResolver<
|
||||
Partial<GQLTwitterMediaConfiguration>
|
||||
>> = {
|
||||
enabled: ({ enabled = false }) => enabled,
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
GQLYouTubeMediaConfiguration,
|
||||
GQLYouTubeMediaConfigurationTypeResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const YouTubeMediaConfiguration: Required<GQLYouTubeMediaConfigurationTypeResolver<
|
||||
Partial<GQLYouTubeMediaConfiguration>
|
||||
>> = {
|
||||
enabled: ({ enabled = false }) => enabled,
|
||||
};
|
||||
@@ -25,6 +25,7 @@ import { ExternalModerationPhase } from "./ExternalModerationPhase";
|
||||
import { FacebookAuthIntegration } from "./FacebookAuthIntegration";
|
||||
import { FeatureCommentPayload } from "./FeatureCommentPayload";
|
||||
import { Flag } from "./Flag";
|
||||
import { GiphyMediaConfiguration } from "./GiphyMediaConfiguration";
|
||||
import { GoogleAuthIntegration } from "./GoogleAuthIntegration";
|
||||
import { Invite } from "./Invite";
|
||||
import { LiveConfiguration } from "./LiveConfiguration";
|
||||
@@ -53,12 +54,14 @@ import { Subscription } from "./Subscription";
|
||||
import { SuspensionStatus } from "./SuspensionStatus";
|
||||
import { SuspensionStatusHistory } from "./SuspensionStatusHistory";
|
||||
import { Tag } from "./Tag";
|
||||
import { TwitterMediaConfiguration } from "./TwitterMediaConfiguration";
|
||||
import { User } from "./User";
|
||||
import { UserModerationScopes } from "./UserModerationScopes";
|
||||
import { UsernameHistory } from "./UsernameHistory";
|
||||
import { UsernameStatus } from "./UsernameStatus";
|
||||
import { UserStatus } from "./UserStatus";
|
||||
import { WebhookEndpoint } from "./WebhookEndpoint";
|
||||
import { YouTubeMediaConfiguration } from "./YouTubeMediaConfiguration";
|
||||
|
||||
const Resolvers: GQLResolver = {
|
||||
ApproveCommentPayload,
|
||||
@@ -83,6 +86,7 @@ const Resolvers: GQLResolver = {
|
||||
FacebookAuthIntegration,
|
||||
FeatureCommentPayload,
|
||||
Flag,
|
||||
GiphyMediaConfiguration,
|
||||
GoogleAuthIntegration,
|
||||
Invite,
|
||||
LiveConfiguration,
|
||||
@@ -112,6 +116,7 @@ const Resolvers: GQLResolver = {
|
||||
SuspensionStatus,
|
||||
SuspensionStatusHistory,
|
||||
Tag,
|
||||
TwitterMediaConfiguration,
|
||||
Time,
|
||||
User,
|
||||
UserModerationScopes,
|
||||
@@ -119,6 +124,7 @@ const Resolvers: GQLResolver = {
|
||||
UsernameStatus,
|
||||
UserStatus,
|
||||
WebhookEndpoint,
|
||||
YouTubeMediaConfiguration,
|
||||
};
|
||||
|
||||
export default Resolvers;
|
||||
|
||||
@@ -1749,7 +1749,7 @@ type Settings {
|
||||
"""
|
||||
media is the configuration media content attached to Comment's.
|
||||
"""
|
||||
media: MediaConfiguration
|
||||
media: MediaConfiguration!
|
||||
|
||||
"""
|
||||
featureFlags provides the enabled feature flags.
|
||||
@@ -4422,7 +4422,7 @@ input GiphyMediaConfigurationInput {
|
||||
"""
|
||||
maximum allowed rating for gifs, g, pg, pg-13, r
|
||||
"""
|
||||
maxRating: String!
|
||||
maxRating: String
|
||||
|
||||
"""
|
||||
key is the API key for Giphy.
|
||||
|
||||
Reference in New Issue
Block a user