5.4.0 Release Bug Fixes (#2789)

* fix: addresses CORL-848

Fixed copy for new commenters feature.

* fix: address CORL-847

Revert the line hight changes on select fields for now.

* fix: addressed CORL-851

Changed copy on CSS field.

* fix: addressed CORL-840

Changed deletion window to 24 hours.
Refactored durations to use TIME enum.
This commit is contained in:
Wyatt Johnson
2020-01-14 16:39:21 +00:00
committed by GitHub
parent a88644d98e
commit 9b8ab6de5f
36 changed files with 1061 additions and 1063 deletions
+9 -6
View File
@@ -5,13 +5,15 @@ import { MongoError } from "mongodb";
import uuid from "uuid";
import { VError } from "verror";
import { ALLOWED_USERNAME_CHANGE_FREQUENCY } from "coral-common/constants";
import { ALLOWED_USERNAME_CHANGE_TIMEFRAME_DURATION } from "coral-common/constants";
import { ERROR_CODES, ERROR_TYPES } from "coral-common/errors";
import { reduceSeconds, UNIT } from "coral-common/helpers/i18n";
import { reduceSeconds } from "coral-common/helpers/i18n";
import TIME from "coral-common/time";
import { Writable } from "coral-common/types";
import { translate } from "coral-server/services/i18n";
import { Writable } from "coral-common/types";
import { GQLUSER_AUTH_CONDITIONS } from "coral-server/graph/schema/__generated__/types";
import { ERROR_TRANSLATIONS } from "./translations";
/**
@@ -315,9 +317,10 @@ export class UsernameAlreadySetError extends CoralError {
export class UsernameUpdatedWithinWindowError extends CoralError {
constructor(lastUpdate: Date) {
const { scaled, unit } = reduceSeconds(ALLOWED_USERNAME_CHANGE_FREQUENCY, [
UNIT.DAYS,
]);
const { scaled, unit } = reduceSeconds(
ALLOWED_USERNAME_CHANGE_TIMEFRAME_DURATION,
[TIME.DAY]
);
super({
code: ERROR_CODES.USERNAME_UPDATED_WITHIN_WINDOW,
context: {
+3 -7
View File
@@ -45,13 +45,9 @@ export function getStoryClosedAt(
if (tenant.closeCommenting.auto) {
// Auto-close stream has been enabled, convert the createdAt time into the
// closedAt time by adding the closedTimeout.
return (
DateTime.fromJSDate(story.createdAt)
// closedTimeout is in seconds, so multiply by 1000 to get
// milliseconds.
.plus(tenant.closeCommenting.timeout * 1000)
.toJSDate()
);
return DateTime.fromJSDate(story.createdAt)
.plus({ seconds: tenant.closeCommenting.timeout })
.toJSDate();
}
return;
+6 -10
View File
@@ -2,8 +2,9 @@ import { isEmpty } from "lodash";
import { Db } from "mongodb";
import uuid from "uuid";
import { DEFAULT_SESSION_LENGTH } from "coral-common/constants";
import { DEFAULT_SESSION_DURATION } from "coral-common/constants";
import { LanguageCode } from "coral-common/helpers/i18n/locales";
import TIME from "coral-common/time";
import { DeepPartial, Omit, Sub } from "coral-common/types";
import { dotize } from "coral-common/utils/dotize";
import { Settings } from "coral-server/models/settings";
@@ -99,16 +100,12 @@ export async function createTenant(
premodLinksEnable: false,
closeCommenting: {
auto: false,
// 2 weeks timeout.
timeout: 60 * 60 * 24 * 7 * 2,
timeout: 2 * TIME.WEEK,
},
disableCommenting: {
enabled: false,
},
// 30 seconds edit window length.
editCommentWindowLength: 30,
editCommentWindowLength: 30 * TIME.SECOND,
charCount: {
enabled: false,
},
@@ -117,7 +114,7 @@ export async function createTenant(
banned: [],
},
auth: {
sessionDuration: DEFAULT_SESSION_LENGTH,
sessionDuration: DEFAULT_SESSION_DURATION,
integrations: {
local: {
enabled: true,
@@ -169,8 +166,7 @@ export async function createTenant(
},
recentCommentHistory: {
enabled: false,
// 7 days in seconds.
timeFrame: 604800,
timeFrame: 7 * TIME.DAY,
// Rejection rate defaulting to 30%, once exceeded, comments will be
// pre-moderated.
triggerRejectionRate: 0.3,
+3 -3
View File
@@ -1,6 +1,7 @@
import Queue, { Job, Queue as QueueType } from "bull";
import Logger from "bunyan";
import TIME from "coral-common/time";
import logger from "coral-server/logger";
export interface TaskOptions<T, U = any> {
@@ -31,11 +32,10 @@ export default class Task<T, U = any> {
// with completed entries if we don't need to.
removeOnComplete: true,
// By default, configure jobs to use an exponential backoff
// strategy starting at a 10 second delay.
// By default, configure jobs to use an exponential backoff strategy.
backoff: {
type: "exponential",
delay: 10000,
delay: 10 * TIME.SECOND,
},
// Be default, try all jobs at least 5 times.
@@ -23,13 +23,9 @@ export function getCommentEditableUntilDate(
tenant: Pick<Tenant, "editCommentWindowLength">,
createdAt: Date
): Date {
return (
DateTime.fromJSDate(createdAt)
// editCommentWindowLength is in seconds, so multiply by 1000 to get
// milliseconds.
.plus(tenant.editCommentWindowLength * 1000)
.toJSDate()
);
return DateTime.fromJSDate(createdAt)
.plus({ seconds: tenant.editCommentWindowLength })
.toJSDate();
}
export async function addTag(
+2 -2
View File
@@ -7,7 +7,7 @@ import { DateTime } from "luxon";
import { Bearer, BearerOptions } from "permit";
import uuid from "uuid/v4";
import { DEFAULT_SESSION_LENGTH } from "coral-common/constants";
import { DEFAULT_SESSION_DURATION } from "coral-common/constants";
import { Omit } from "coral-common/types";
import {
AuthenticationError,
@@ -262,7 +262,7 @@ export const signTokenString = async (
secret,
{
jwtid: uuid(),
expiresIn: DEFAULT_SESSION_LENGTH,
expiresIn: DEFAULT_SESSION_DURATION,
...options,
issuer: tenant.id,
subject: user.id,
+8 -8
View File
@@ -2,11 +2,11 @@ import { DateTime } from "luxon";
import { Db } from "mongodb";
import {
ALLOWED_USERNAME_CHANGE_FREQUENCY,
COMMENT_REPEAT_POST_TIMESPAN,
DOWNLOAD_LIMIT_TIMEFRAME,
ALLOWED_USERNAME_CHANGE_TIMEFRAME_DURATION,
COMMENT_REPEAT_POST_DURATION,
DOWNLOAD_LIMIT_TIMEFRAME_DURATION,
} from "coral-common/constants";
import { SCHEDULED_DELETION_TIMESPAN_DAYS } from "coral-common/constants";
import { SCHEDULED_DELETION_WINDOW_DURATION } from "coral-common/constants";
import { Config } from "coral-server/config";
import {
DuplicateEmailError,
@@ -369,7 +369,7 @@ export async function requestAccountDeletion(
}
const deletionDate = DateTime.fromJSDate(now).plus({
days: SCHEDULED_DELETION_TIMESPAN_DAYS,
seconds: SCHEDULED_DELETION_WINDOW_DURATION,
});
const updatedUser = await scheduleDeletionDate(
@@ -528,7 +528,7 @@ export async function updateUsername(
// Get the earliest date that the username could have been edited before to/
// allow it now.
const lastUsernameEditAllowed = DateTime.fromJSDate(now)
.plus({ seconds: -ALLOWED_USERNAME_CHANGE_FREQUENCY })
.plus({ seconds: -ALLOWED_USERNAME_CHANGE_TIMEFRAME_DURATION })
.toJSDate();
const { history } = user.status.username;
@@ -1118,7 +1118,7 @@ export async function requestCommentsDownload(
if (
user.lastDownloadedAt &&
DateTime.fromJSDate(user.lastDownloadedAt)
.plus({ seconds: DOWNLOAD_LIMIT_TIMEFRAME })
.plus({ seconds: DOWNLOAD_LIMIT_TIMEFRAME_DURATION })
.toSeconds() >= DateTime.fromJSDate(now).toSeconds()
) {
throw new Error("requested download too early");
@@ -1212,7 +1212,7 @@ export async function updateUserLastCommentID(
) {
const key = userLastCommentIDKey(tenant, user);
await redis.set(key, commentID, "EX", COMMENT_REPEAT_POST_TIMESPAN);
await redis.set(key, commentID, "EX", COMMENT_REPEAT_POST_DURATION);
}
/**
+3 -7
View File
@@ -42,13 +42,9 @@ function getLastCommentEditableUntilDate(
tenant: Pick<Tenant, "editCommentWindowLength">,
now = new Date()
): Date {
return (
DateTime.fromJSDate(now)
// editCommentWindowLength is in seconds, so multiply by 1000 to get
// milliseconds.
.minus(tenant.editCommentWindowLength * 1000)
.toJSDate()
);
return DateTime.fromJSDate(now)
.minus({ seconds: tenant.editCommentWindowLength })
.toJSDate();
}
export type EditComment = Omit<