|
|
@ -97,6 +97,11 @@ class ArchiveUserLocalJob extends SiteWorkerProcess {
|
|
|
|
await this.archiveUserStickers(job);
|
|
|
|
await this.archiveUserStickers(job);
|
|
|
|
await this.archiveUserImages(job);
|
|
|
|
await this.archiveUserImages(job);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Archive DTP Sites specific content
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
await this.archiveUserPosts(job);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Create the .zip file archive, upload it to storage, and create the
|
|
|
|
* Create the .zip file archive, upload it to storage, and create the
|
|
|
|
* UserArchive record.
|
|
|
|
* UserArchive record.
|
|
|
@ -309,6 +314,33 @@ class ArchiveUserLocalJob extends SiteWorkerProcess {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async archiveUserPosts (job) {
|
|
|
|
|
|
|
|
const Post = mongoose.model('Post');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
job.data.postPath = path.join(job.data.workPath, 'posts');
|
|
|
|
|
|
|
|
await fs.promises.mkdir(job.data.postPath, { recursive: true });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.log.info('archiving user blog posts', {
|
|
|
|
|
|
|
|
user: {
|
|
|
|
|
|
|
|
_id: job.data.user._id,
|
|
|
|
|
|
|
|
username: job.data.user.username,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Post
|
|
|
|
|
|
|
|
.find({ author: job.data.user._id })
|
|
|
|
|
|
|
|
.cursor()
|
|
|
|
|
|
|
|
.eachAsync(async (post) => {
|
|
|
|
|
|
|
|
const postFilename = path.join(job.data.postPath, `post-${post._id}.json`);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await fs.promises.writeFile(postFilename, JSON.stringify(post, null, 2));
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
this.log.error('failed to write user blog post file', { postFilename, error });
|
|
|
|
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async createArchiveFile (job) {
|
|
|
|
async createArchiveFile (job) {
|
|
|
|
const { minio: minioService } = this.dtp.services;
|
|
|
|
const { minio: minioService } = this.dtp.services;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|