mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-20 14:47:18 +02:00
fix: distinguish repository publication and settings dates
This commit is contained in:
1 parent
22096a8346
commit
7cdf0f5e8d
12 files changed
+167
-21
No files matched your search
@@ -173,8 +173,10 @@ router.post(
|
||||
const reactivating = repo.status === RepositoryStatus.EXPIRED;
|
||||
const updates: Record<string, Date> = {
|
||||
"options.expirationDate": newExpiration,
|
||||
settingsSavedAt: new Date(),
|
||||
};
|
||||
repo.model.options.expirationDate = newExpiration;
|
||||
repo.model.settingsSavedAt = updates.settingsSavedAt;
|
||||
if (reactivating) {
|
||||
repo.model.anonymizeDate = new Date();
|
||||
updates.anonymizeDate = repo.model.anonymizeDate;
|
||||
@@ -572,6 +574,7 @@ router.post(
|
||||
{ _id: repo.model._id, "githubAccess.revision": previousAccessRevision || { $exists: false } },
|
||||
{
|
||||
$set: {
|
||||
settingsSavedAt: new Date(),
|
||||
options: repo.model.options,
|
||||
source: repo.model.source,
|
||||
githubAccess: repo.model.githubAccess,
|
||||
@@ -647,6 +650,7 @@ router.post("/", async (req, res) => {
|
||||
const repo = new AnonymizedRepositoryModel();
|
||||
repo.repoId = repoUpdate.repoId;
|
||||
repo.anonymizeDate = new Date();
|
||||
repo.settingsSavedAt = repo.anonymizeDate;
|
||||
repo.owner = user.id;
|
||||
repo.githubAccess = selectedAccess.binding;
|
||||
|
||||
|
||||
@@ -385,9 +385,15 @@ router.get(
|
||||
res.json({
|
||||
url: redirectURL,
|
||||
download: download || user?.isAdmin === true,
|
||||
lastUpdateDate: repo.model.source.commitDate
|
||||
? repo.model.source.commitDate
|
||||
: repo.model.anonymizeDate,
|
||||
// Source commits can predate publication by months and do not record
|
||||
// changes to anonymization settings or expiration.
|
||||
lastUpdateDate: new Date(Math.max(...[
|
||||
repo.model.anonymizeDate, repo.model.settingsSavedAt, repo.model.publishedAt,
|
||||
].filter((date): date is Date => !!date).map(date => new Date(date).getTime()))),
|
||||
anonymizedAt: repo.model.anonymizeDate,
|
||||
sourceCommitDate: repo.model.source.commitDate,
|
||||
settingsSavedAt: repo.model.settingsSavedAt,
|
||||
publishedAt: repo.model.publishedAt,
|
||||
isAdmin: user?.isAdmin === true,
|
||||
isOwner: user?.id == repo.model.owner,
|
||||
hasWebsite: !!repo.options.page && !!repo.options.pageSource,
|
||||
|
||||
Reference in new issue
Block a user