Skip to content

Commit

Permalink
handle possibly undefined dsa settings on tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-funk committed Nov 29, 2023
1 parent 8f8fba1 commit d68a7d5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/src/core/server/cron/accountDeletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const deleteScheduledAccounts: ScheduledJobCommand<Options> = async ({
user.id,
tenant.id,
now,
tenant.dsa.enabled
tenant.dsa?.enabled
);

// If the user has an email, then send them a confirmation that their account
Expand Down
2 changes: 1 addition & 1 deletion server/src/core/server/graph/mutators/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const Users = (ctx: GraphContext) => ({
input.userID,
ctx.tenant.id,
ctx.now,
ctx.tenant.dsa.enabled
ctx.tenant.dsa?.enabled
);
},
cancelAccountDeletion: async (
Expand Down
7 changes: 7 additions & 0 deletions server/src/core/server/models/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
GQLAuth,
GQLAuthenticationTargetFilter,
GQLCOMMENT_BODY_FORMAT,
GQLDSA_METHOD_OF_REDRESS,
GQLEmailConfiguration,
GQLFacebookAuthIntegration,
GQLGoogleAuthIntegration,
Expand Down Expand Up @@ -421,8 +422,14 @@ export const defaultRTEConfiguration: RTEConfiguration = {

export interface DSAConfiguration {
enabled: boolean;
methodOfRedress: {
method: GQLDSA_METHOD_OF_REDRESS;
};
}

export const defaultDSAConfiguration: DSAConfiguration = {
enabled: false,
methodOfRedress: {
method: GQLDSA_METHOD_OF_REDRESS.NONE,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import moderate, { Moderate } from "./moderate";

import {
GQLCOMMENT_STATUS,
GQLDSA_METHOD_OF_REDRESS,
GQLUSER_ROLE,
} from "coral-server/graph/schema/__generated__/types";
import { I18n } from "coral-server/services/i18n";
Expand All @@ -23,7 +24,10 @@ jest.mock("coral-server/models/action/moderation/comment");

it("requires a valid rejection reason if dsaFeatures are enabled", async () => {
const tenant = createTenantFixture({
dsa: { enabled: true },
dsa: {
enabled: true,
methodOfRedress: { method: GQLDSA_METHOD_OF_REDRESS.NONE },
},
});
const config = {} as Config;
const story = createStoryFixture({ tenantID: tenant.id });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default async function moderate(
}
) {
if (
tenant.dsa.enabled &&
tenant.dsa?.enabled &&
input.status === GQLCOMMENT_STATUS.REJECTED &&
!input.rejectionReason
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const external: IntermediateModerationPhase = async (ctx) => {
!ctx.tenant.integrations.external ||
ctx.tenant.integrations.external.phases.length === 0 ||
// (marcushaddon) DSA and external moderation are mutually exclusive for the time being
ctx.tenant.dsa.enabled
ctx.tenant.dsa?.enabled
) {
return;
}
Expand Down

0 comments on commit d68a7d5

Please sign in to comment.