Files
anonymous_github/src/core/model/anonymizedGists/anonymizedGists.schema.ts
T
Thomas Durieux 445a479339 fix: deduplicate owner access alerts per recipient (#896)
* fix: prevent duplicate access alerts to the same recipient

* fix: address recipient alert recovery review findings

* fix: reconcile unsent alerts and wait for startup migration

* fix: preserve legacy recipient alerts through upgrades

* fix: reconcile alert results and legacy recovery races

* fix: fence dispatch and clean cancelled alert metadata

* fix: fence alert preparation and retain in-flight recovery

* fix: atomically commit alert dispatch and retry deferred recovery

* fix: keep recovery lookups from blocking upstream file reads
2026-10-13 13:55:10 +01:00

78 lines
1.8 KiB
TypeScript

import { Schema } from "mongoose";
const AnonymizedGistSchema = new Schema({
accessAlertGeneration: { type: String, select: false },
accessAlertClaimedAt: { type: Date, select: false },
accessAlertAttemptId: { type: String, select: false },
accessAlertClaimRevision: { type: Number, select: false },
gistId: {
type: String,
index: { unique: true },
},
status: {
type: String,
default: "preparing",
},
statusDate: Date,
statusMessage: String,
anonymizeDate: Date,
lastView: Date,
pageView: Number,
owner: { type: Schema.Types.ObjectId, index: true },
conference: String,
source: {
gistId: String,
accessToken: { type: String, select: false },
},
options: {
terms: [String],
expirationMode: { type: String },
expirationDate: Date,
update: Boolean,
image: Boolean,
link: Boolean,
title: Boolean,
body: Boolean,
comments: Boolean,
content: Boolean,
origin: Boolean,
username: Boolean,
date: Boolean,
},
dateOfEntry: {
type: Date,
default: Date.now,
},
gist: {
description: String,
isPublic: Boolean,
creationDate: Date,
updatedDate: Date,
ownerLogin: String,
files: [
{
filename: String,
content: String,
language: String,
size: Number,
// `type` is a reserved key in Mongoose type declarations; without the
// nested `{ type: String }` the whole object is compiled as an array
// of strings and file objects are silently dropped on save.
type: { type: String },
},
],
comments: [
{
body: String,
creationDate: Date,
updatedDate: Date,
author: String,
},
],
},
});
AnonymizedGistSchema.index({ status: 1, "options.expirationDate": 1 });
export default AnonymizedGistSchema;