schemas.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. var Schemas = {};
  2. Schemas.FullSong = new SimpleSchema({
  3. "id": {
  4. type: String,
  5. label: "Song YouTube id"
  6. },
  7. "mid": {
  8. type: String,
  9. label: "Song mid"
  10. },
  11. "likes": {
  12. type: Number,
  13. label: "Song likes",
  14. defaultValue: 0
  15. },
  16. "dislikes": {
  17. type: Number,
  18. label: "Song dislikes",
  19. defaultValue: 0
  20. },
  21. "title": {
  22. type: String,
  23. label: "Song title"
  24. },
  25. "artist": {
  26. type: String,
  27. label: "Song artist"
  28. },
  29. "img": {
  30. type: String,
  31. label: "Song img"
  32. },
  33. "duration": {
  34. type: Number,
  35. label: "Song duration",
  36. min: 0,
  37. decimal: true
  38. },
  39. "skipDuration": {
  40. type: Number,
  41. label: "Song skipDuration",
  42. min: 0,
  43. decimal: true
  44. },
  45. "requestedBy": {
  46. type: String,
  47. label: "User ID of the person who requested the song"
  48. },
  49. "approvedBy": {
  50. type: String,
  51. label: "User ID of the person who approved the song"
  52. }
  53. });
  54. Schemas.QueueSong = new SimpleSchema({
  55. "id": {
  56. type: String,
  57. label: "Song YouTube id"
  58. },
  59. "mid": {
  60. type: String,
  61. label: "Song mid"
  62. },
  63. "likes": {
  64. type: Number,
  65. label: "Song likes",
  66. defaultValue: 0
  67. },
  68. "dislikes": {
  69. type: Number,
  70. label: "Song dislikes",
  71. defaultValue: 0
  72. },
  73. "title": {
  74. type: String,
  75. label: "Song title"
  76. },
  77. "artist": {
  78. type: String,
  79. label: "Song artist"
  80. },
  81. "img": {
  82. type: String,
  83. label: "Song img"
  84. },
  85. "duration": {
  86. type: Number,
  87. label: "Song duration",
  88. min: 0,
  89. decimal: true
  90. },
  91. "skipDuration": {
  92. type: Number,
  93. label: "Song skipDuration",
  94. min: 0,
  95. decimal: true
  96. },
  97. "requestedBy": {
  98. type: String,
  99. label: "User ID of the person who requested the song"
  100. }
  101. });
  102. Schemas.Chat = new SimpleSchema({
  103. type: {
  104. type: String,
  105. label: "Type of the room a message was sent in",
  106. regEx: /^[a-z0-9_]{1,20}$/
  107. },
  108. rawrank: {
  109. type: String,
  110. label: "Rank of the user who sent the message"
  111. },
  112. rank: {
  113. type: String,
  114. label: "Display tag of the rank of the user who sent a message",
  115. optional: true
  116. },
  117. message: {
  118. type: String,
  119. label: "The message",
  120. max: 300
  121. },
  122. username: {
  123. type: String,
  124. label: "Username of the user who sent the message"
  125. },
  126. time: {
  127. type: Date,
  128. label: "Date of the time the message was sent"
  129. }
  130. });
  131. Schemas.Alert = new SimpleSchema({
  132. description: {
  133. type: String,
  134. label: "The Alert's Description"
  135. },
  136. priority: {
  137. type: String,
  138. allowedValues: ["danger", "warning", "success", "primary"],
  139. label: "The Alert's Priority"
  140. },
  141. active: {
  142. type: Boolean,
  143. label: "Whether or not the alert is active or not"
  144. },
  145. createdBy: {
  146. type: String,
  147. label: "Username of the person who created an alert"
  148. }
  149. });
  150. Schemas.Feedback = new SimpleSchema({
  151. messages: {
  152. type: Array,
  153. label: "Array of feedback messages"
  154. },
  155. "messages.$": {
  156. type: Object,
  157. label: "Object for each feedback"
  158. },
  159. "messages.$.username": {
  160. type: String,
  161. label: "Username of user who submitted feedback"
  162. },
  163. "messages.$.message": {
  164. type: String,
  165. label: "Feedback message"
  166. },
  167. "messages.$.upvotes": {
  168. type: Number,
  169. defaultValue: 0,
  170. min: 0,
  171. label: "Number of upvotes for a particualar feedback"
  172. },
  173. "messages.$.upvotedBy": {
  174. type: Array,
  175. label: "Array of users who have upvoted a feedback"
  176. },
  177. "messages.$.upvotedBy.$": {
  178. type: String,
  179. label: "Username of user who upvoted a feedback"
  180. }
  181. });
  182. Schemas.Room = new SimpleSchema({
  183. display: {
  184. type: String,
  185. label: "Room Display Name",
  186. regEx: /^[a-z0-9A-Z_\s]{1,30}$/
  187. },
  188. type: {
  189. type: String,
  190. label: "Room Type",
  191. regEx: /^[a-z0-9_]{1,20}$/
  192. },
  193. currentSong: {
  194. type: Object,
  195. defaultValue: {},
  196. label: "Current Song"
  197. },
  198. "currentSong.song": {
  199. type: Schemas.FullSong,
  200. label: "Current Song Object"
  201. },
  202. "currentSong.started": {
  203. type: Number,
  204. label: "Current Song Start Date"
  205. },
  206. timePaused: {
  207. type: Number,
  208. defaultValue: 0,
  209. label: "Amount of time a room has been paused for"
  210. },
  211. users: {
  212. type: Number,
  213. defaultValue: 0,
  214. label: "Users Online",
  215. min: 0
  216. },
  217. state: {
  218. type: String,
  219. defaultValue: "paused",
  220. allowedValues: ["paused", "playing"],
  221. label: "Room State"
  222. },
  223. votes: {
  224. type: Number,
  225. defaultValue: 0,
  226. label: "Current votes to skip current song",
  227. min: 0
  228. },
  229. private: {
  230. type: Boolean,
  231. defaultValue: false,
  232. label: "Room private or not"
  233. }
  234. });
  235. Schemas.Playlist = new SimpleSchema({
  236. type: {
  237. type: String,
  238. label: "Type of the room the playlist is for",
  239. regEx: /^[a-z0-9_]{1,20}$/
  240. },
  241. songs: {
  242. type: Array,
  243. label: "All songs in that playlist"
  244. },
  245. "songs.$": {
  246. type: Schemas.FullSong,
  247. label: "Song object"
  248. },
  249. lastSong: {
  250. type: Number,
  251. label: "Index of the previous song",
  252. defaultValue: 0
  253. }
  254. });
  255. Schemas.Queue = new SimpleSchema({
  256. type: {
  257. type: String,
  258. label: "Type of the room the playlist is for",
  259. regEx: /^[a-z0-9_]{1,20}$/
  260. },
  261. songs: {
  262. type: Array,
  263. label: "All songs in that playlist"
  264. },
  265. "songs.$": {
  266. type: Schemas.QueueSong,
  267. label: "Song object"
  268. }
  269. });
  270. Schemas.UserProfile = new SimpleSchema({
  271. username: {
  272. type: String,
  273. label: "Username",
  274. regEx: /^[a-zA-Z0-9_]+$/,
  275. min: 4,
  276. max: 26
  277. },
  278. usernameL: {
  279. type: String,
  280. label: "Username in lowercase",
  281. regEx: /^[a-z0-9_]+$/
  282. },
  283. realname: {
  284. type: String,
  285. label: "Real Name",
  286. regEx: /^[A-Za-z0-9 .'-]+$/,
  287. optional: true
  288. },
  289. rank: {
  290. type: String,
  291. label: "Rank",
  292. allowedValues: ["default", "moderator", "admin"]
  293. },
  294. liked: {
  295. type: Array,
  296. label: "User's Liked songs"
  297. },
  298. "liked.$": {
  299. type: String,
  300. label: "A MID of a song a user liked"
  301. },
  302. disliked: {
  303. type: Array,
  304. label: "User's Disliked songs"
  305. },
  306. "disliked.$": {
  307. type: String,
  308. label: "A MID of a song a user disliked"
  309. },
  310. settings: {
  311. type: Object,
  312. label: "The settings of a user"
  313. },
  314. "settings.showRating": {
  315. type: Boolean,
  316. label: "If a user wants their liked and disliked songs to show up for everyone",
  317. defaultValue: false
  318. },
  319. statistics: {
  320. type: Object,
  321. label: "The statistics of a user"
  322. },
  323. "statistics.songsRequested": {
  324. type: Number,
  325. label: "Amount of songs the user has requested",
  326. defaultValue: 0
  327. }
  328. });
  329. Schemas.UserPunishments = new SimpleSchema({
  330. mute: {
  331. type: Object,
  332. label: "User's Current Mute Info",
  333. optional: true
  334. },
  335. "mute.mutedBy": {
  336. type: String,
  337. label: "Muted By"
  338. },
  339. "mute.mutedAt": {
  340. type: Date,
  341. label: "Muted At"
  342. },
  343. "mute.mutedUntil": {
  344. type: Date,
  345. label: "Muted Until"
  346. },
  347. mutes: {
  348. type: Array,
  349. label: "All of the mutes of a user",
  350. optional: true
  351. },
  352. "mutes.$": {
  353. type: Object,
  354. label: "One of the mutes of a user"
  355. },
  356. "mutes.$.mutedBy": {
  357. type: String,
  358. label: "Muted By"
  359. },
  360. "mutes.$.mutedAt": {
  361. type: Date,
  362. label: "Muted At"
  363. },
  364. "mutes.$.mutedUntil": {
  365. type: Date,
  366. label: "Muted Until"
  367. },
  368. ban: {
  369. type: Object,
  370. label: "User's Current Ban Info",
  371. optional: true
  372. },
  373. "ban.bannedBy": {
  374. type: String,
  375. label: "Banned By"
  376. },
  377. "ban.bannedAt": {
  378. type: Date,
  379. label: "Banned At"
  380. },
  381. "ban.bannedUntil": {
  382. type: Date,
  383. label: "Banned Until"
  384. },
  385. bans: {
  386. type: Array,
  387. label: "All of the bans of a user",
  388. optional: true
  389. },
  390. "bans.$": {
  391. type: Object,
  392. label: "One of the bans of a user"
  393. },
  394. "bans.$.bannedBy": {
  395. type: String,
  396. label: "Banned By"
  397. },
  398. "bans.$.bannedAt": {
  399. type: Date,
  400. label: "Banned At"
  401. },
  402. "bans.$.bannedUntil": {
  403. type: Date,
  404. label: "Banned Until"
  405. }
  406. });
  407. Schemas.User = new SimpleSchema({
  408. username: {
  409. type: String,
  410. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  411. // optional here because the accounts-password package does its own validation.
  412. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  413. optional: true,
  414. regEx: /^[a-zA-Z0-9_]+$/,
  415. min: 6,
  416. max: 26
  417. },
  418. emails: {
  419. type: Array,
  420. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  421. // optional here because the accounts-password package does its own validation.
  422. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  423. optional: true
  424. },
  425. "emails.$": {
  426. type: Object
  427. },
  428. "emails.$.address": {
  429. type: String,
  430. regEx: SimpleSchema.RegEx.Email
  431. },
  432. "emails.$.verified": {
  433. type: Boolean
  434. },
  435. createdAt: {
  436. type: Date
  437. },
  438. profile: {
  439. type: Schemas.UserProfile
  440. },
  441. punishments: {
  442. type: Schemas.UserPunishments,
  443. defaultValue: {mutes: [], bans: []}
  444. },
  445. // Make sure this services field is in your schema if you're using any of the accounts packages
  446. services: {
  447. type: Object,
  448. optional: true,
  449. blackbox: true
  450. },
  451. // In order to avoid an 'Exception in setInterval callback' from Meteor
  452. heartbeat: {
  453. type: Date,
  454. optional: true
  455. }
  456. });
  457. Schemas.Report = new SimpleSchema({
  458. room: {
  459. type: String,
  460. label: "Type of the room that the reports are from",
  461. regEx: /^[a-z0-9_]{1,20}$/
  462. },
  463. report: {
  464. type: Array,
  465. label: "The reports"
  466. },
  467. "report.$": {
  468. type: Object,
  469. label: "A report"
  470. },
  471. "report.$.song": {
  472. type: String,
  473. label: "A report's song MID"
  474. },
  475. "report.$.type": {
  476. type: Array,
  477. label: "The types of things a song was reported for"
  478. },
  479. "report.$.type.$": {
  480. type: String,
  481. label: "A type of thing a report was reported for",
  482. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  483. },
  484. "report.$.reason": {
  485. type: Array,
  486. label: "The reasons a song was reported for"
  487. },
  488. "report.$.reason.$": {
  489. type: String,
  490. label: "A reason a song was reported for",
  491. allowedValues: ["report-song-not-playing", "report-song-does-not-exist", "report-song-other", "report-title-incorrect", "report-title-inappropriate", "report-title-other", "report-author-incorrect", "report-author-inappropriate", "report-author-other", "report-duration-long", "report-duration-short", "report-duration-other", "report-audio-inappropriate", "report-audio-not-playing", "report-audio-other", "report-albumart-incorrect", "report-albumart-inappropriate", "report-albumart-not-showing", "report-albumart-other"]
  492. },
  493. "report.$.other": {
  494. type: String,
  495. label: "Other",
  496. optional: true
  497. }
  498. });
  499. Rooms.attachSchema(Schemas.Room);
  500. Alerts.attachSchema(Schemas.Alert);
  501. Chat.attachSchema(Schemas.Chat);
  502. Playlists.attachSchema(Schemas.Playlist);
  503. Queues.attachSchema(Schemas.Queue);
  504. Meteor.users.attachSchema(Schemas.User);
  505. Reports.attachSchema(Schemas.Report);
  506. Feedback.attachSchema(Schemas.Feedback);