Add user ID tracking for versions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -7,15 +7,16 @@ class VersionedModel extends Model {
|
||||
version_archive: [Object],
|
||||
version_num: { type: Number, default: 1 },
|
||||
version_create_date: { type: Date, default: () => new Date },
|
||||
version_user_id: String,
|
||||
}
|
||||
}
|
||||
|
||||
async version_save(message = undefined) {
|
||||
await this.new_version(message)
|
||||
async version_save(message = undefined, user_id = undefined) {
|
||||
await this.new_version(message, user_id)
|
||||
return this.save()
|
||||
}
|
||||
|
||||
async new_version(message = undefined) {
|
||||
async new_version(message = undefined, user_id = undefined) {
|
||||
const version_data = await this.cast_to_version_data()
|
||||
version_data.version_UUID = uuid()
|
||||
version_data.version_message = message
|
||||
@@ -26,6 +27,7 @@ class VersionedModel extends Model {
|
||||
this.version_num += 1
|
||||
this.version_archive.push(version_data)
|
||||
this.version_create_date = new Date()
|
||||
this.version_user_id = user_id
|
||||
}
|
||||
|
||||
async cast_to_version_data() {
|
||||
|
||||
@@ -203,7 +203,7 @@ class Page extends VersionedModel {
|
||||
this[`shared_users_${level}`].push(user._id)
|
||||
|
||||
// TODO replace user.uid with name of user when we support that
|
||||
await this.version_save(`Shared with ${user.uid} (${level} access)`)
|
||||
await this.version_save(`Shared with ${user.uid} (${level} access)`, user.id)
|
||||
await user.save()
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ class Page extends VersionedModel {
|
||||
this.shared_users_update = this.shared_users_update.filter(x => String(x) !== user.id)
|
||||
this.shared_users_manage = this.shared_users_manage.filter(x => String(x) !== user.id)
|
||||
|
||||
await this.version_save(`Unshared with ${user.uid}`)
|
||||
await this.version_save(`Unshared with ${user.uid}`, user.id)
|
||||
await user.save()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user