Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Petrov Day 2022 #5730

Merged
merged 9 commits into from Sep 22, 2022
add createdAt to permissions
  • Loading branch information
darkruby501 committed Sep 22, 2022
commit c5971d116381c9e1cb5c87132b2e3cd0caa9d379
1 change: 1 addition & 0 deletions packages/lesswrong/lib/collections/users/schema.ts
Expand Up @@ -712,6 +712,7 @@ const schema: SchemaType<DbUser> = {
order: 95,
type: Boolean,
optional: true,
b0b3rt marked this conversation as resolved.
Show resolved Hide resolved
nullable: true,
group: formGroups.siteCustomizations,
defaultValue: false,
canRead: ['guests'],
Expand Down
8 changes: 5 additions & 3 deletions packages/lesswrong/lib/petrovHelpers.ts
@@ -1,4 +1,5 @@
import { petrovBeforeTime } from "../components/Layout";
import moment from "moment";

export const getPetrovDayKarmaThreshold = (): number => {
const petrovStartTime = petrovBeforeTime.get()
Expand All @@ -10,11 +11,12 @@ export const getPetrovDayKarmaThreshold = (): number => {
export const userCanLaunchPetrovMissile = (user: UsersCurrent|DbUser|null): boolean => {
const currentKarmaThreshold = getPetrovDayKarmaThreshold()
const manuallyExcludedUsers: String[] = ['aaaa']
const userCreatedBeforeCutoff = moment('2022-09-21').isSameOrAfter(moment(user?.createdAt))

return !!user && !(manuallyExcludedUsers.includes(user._id)
return !!user && userCreatedBeforeCutoff && !(manuallyExcludedUsers.includes(user._id)
|| !!user.banned
|| user.deleted
|| (user.karma < currentKarmaThreshold)
|| (user.karma < 0)
|| (user.karma && user.karma < currentKarmaThreshold)
|| (user.karma && user.karma < 0)
|| user.petrovOptOut)
}