diff options
author | Raphael <raphaelkabo@hey.com> | 2023-05-12 17:03:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 17:03:13 +0100 |
commit | 67cf89fd0cfdf56c7e6d6d9bdf93d95d679ce2a1 (patch) | |
tree | c66bdf874a210997cd1d84942101773ba0175b20 /src/models/Event.js | |
parent | a75aad783c117aaef2ec19b6b434be0f0d7e57de (diff) | |
parent | 50688f573054f60aa7594672615f11713173c147 (diff) |
Merge pull request #95 from lowercasename/typescript
Migrate to TypeScript and PNPM
Diffstat (limited to 'src/models/Event.js')
-rwxr-xr-x | src/models/Event.js | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/src/models/Event.js b/src/models/Event.js new file mode 100755 index 0000000..234084a --- /dev/null +++ b/src/models/Event.js @@ -0,0 +1,259 @@ +const mongoose = require("mongoose"); + +const Attendees = new mongoose.Schema({ + name: { + type: String, + trim: true, + }, + status: { + type: String, + trim: true, + }, + email: { + type: String, + trim: true, + }, + removalPassword: { + type: String, + trim: true, + unique: true, + sparse: true, + }, + id: { + type: String, + trim: true, + unique: true, + sparse: true, + }, + // The number of people that are attending under one 'attendee' object + number: { + type: Number, + trim: true, + default: 1, + }, + created: Date, +}); + +const Followers = new mongoose.Schema( + { + // this is the id of the original follow *request*, which we use to validate Undo events + followId: { + type: String, + trim: true, + }, + // this is the actual remote user profile id + actorId: { + type: String, + trim: true, + }, + // this is the stringified JSON of the entire user profile + actorJson: { + type: String, + trim: true, + }, + name: { + type: String, + trim: true, + }, + }, + { _id: false } +); + +const ReplySchema = new mongoose.Schema({ + id: { + type: String, + required: true, + unique: true, + sparse: true, + }, + author: { + type: String, + trim: true, + required: true, + }, + content: { + type: String, + trim: true, + required: true, + }, + timestamp: { + type: Date, + trim: true, + required: true, + }, +}); + +const ActivityPubMessages = new mongoose.Schema({ + id: { + type: String, + required: true, + unique: true, + sparse: true, + }, + content: { + type: String, + trim: true, + required: true, + }, +}); + +const CommentSchema = new mongoose.Schema({ + id: { + type: String, + required: true, + unique: true, + sparse: true, + }, + author: { + type: String, + trim: true, + required: true, + }, + content: { + type: String, + trim: true, + required: true, + }, + timestamp: { + type: Date, + trim: true, + required: true, + }, + activityJson: { + type: String, + trim: true, + }, + actorJson: { + type: String, + trim: true, + }, + activityId: { + type: String, + trim: true, + }, + actorId: { + type: String, + trim: true, + }, + replies: [ReplySchema], +}); + +const EventSchema = new mongoose.Schema({ + id: { + type: String, + required: true, + unique: true, + }, + type: { + type: String, + trim: true, + required: true, + }, + name: { + type: String, + trim: true, + required: true, + }, + location: { + type: String, + trim: true, + required: true, + }, + start: { + // Stored as a UTC timestamp + type: Date, + trim: true, + required: true, + }, + end: { + // Stored as a UTC timestamp + type: Date, + trim: true, + required: true, + }, + timezone: { + type: String, + default: "Etc/UTC", + }, + description: { + type: String, + trim: true, + required: true, + }, + image: { + type: String, + trim: true, + }, + url: { + type: String, + trim: true, + }, + creatorEmail: { + type: String, + trim: true, + }, + hostName: { + type: String, + trim: true, + }, + viewPassword: { + type: String, + trim: true, + }, + editPassword: { + type: String, + trim: true, + }, + editToken: { + type: String, + trim: true, + minlength: 32, + maxlength: 32, + }, + eventGroup: { type: mongoose.Schema.Types.ObjectId, ref: "EventGroup" }, + usersCanAttend: { + type: Boolean, + trim: true, + default: false, + }, + showUsersList: { + type: Boolean, + trim: true, + default: false, + }, + usersCanComment: { + type: Boolean, + trim: true, + default: false, + }, + firstLoad: { + type: Boolean, + trim: true, + default: true, + }, + attendees: [Attendees], + maxAttendees: { + type: Number, + }, + comments: [CommentSchema], + activityPubActor: { + type: String, + trim: true, + }, + activityPubEvent: { + type: String, + trim: true, + }, + publicKey: { + type: String, + trim: true, + }, + privateKey: { + type: String, + trim: true, + }, + followers: [Followers], + activityPubMessages: [ActivityPubMessages], +}); + +module.exports = mongoose.model("Event", EventSchema); |