schemas.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. "genres": {
  46. type: Array,
  47. label: "Array of song genre's"
  48. },
  49. "genres.$": {
  50. type: String,
  51. label: "Song genre"
  52. },
  53. "requestedBy": {
  54. type: String,
  55. label: "User ID of the person who requested the song"
  56. },
  57. "approvedBy": {
  58. type: String,
  59. label: "User ID of the person who approved the song"
  60. }
  61. });
  62. Schemas.UserSong = new SimpleSchema({
  63. "id": {
  64. type: String,
  65. label: "Song YouTube id"
  66. },
  67. "title": {
  68. type: String,
  69. label: "Song title"
  70. },
  71. "duration": {
  72. type: Number,
  73. label: "Song duration",
  74. min: 0,
  75. decimal: true
  76. }
  77. });
  78. Schemas.QueueSong = new SimpleSchema({
  79. "id": {
  80. type: String,
  81. label: "Song YouTube id"
  82. },
  83. "mid": {
  84. type: String,
  85. label: "Song mid"
  86. },
  87. "likes": {
  88. type: Number,
  89. label: "Song likes",
  90. defaultValue: 0
  91. },
  92. "dislikes": {
  93. type: Number,
  94. label: "Song dislikes",
  95. defaultValue: 0
  96. },
  97. "title": {
  98. type: String,
  99. label: "Song title"
  100. },
  101. "artist": {
  102. type: String,
  103. label: "Song artist"
  104. },
  105. "img": {
  106. type: String,
  107. label: "Song img"
  108. },
  109. "duration": {
  110. type: Number,
  111. label: "Song duration",
  112. min: 0,
  113. decimal: true
  114. },
  115. "skipDuration": {
  116. type: Number,
  117. label: "Song skipDuration",
  118. min: 0,
  119. decimal: true
  120. },
  121. "genres": {
  122. type: Array,
  123. label: "Array of song genre's"
  124. },
  125. "genres.$": {
  126. type: String,
  127. label: "Song genre"
  128. },
  129. "requestedBy": {
  130. type: String,
  131. label: "User ID of the person who requested the song"
  132. }
  133. });
  134. Schemas.Chat = new SimpleSchema({
  135. type: {
  136. type: String,
  137. label: "Type of the room a message was sent in",
  138. regEx: /^[a-z0-9_]{1,20}$/
  139. },
  140. rawrank: {
  141. type: String,
  142. label: "Rank of the user who sent the message"
  143. },
  144. rank: {
  145. type: String,
  146. label: "Display tag of the rank of the user who sent a message",
  147. optional: true
  148. },
  149. message: {
  150. type: String,
  151. label: "The message",
  152. max: 300
  153. },
  154. username: {
  155. type: String,
  156. label: "Username of the user who sent the message"
  157. },
  158. time: {
  159. type: Date,
  160. label: "Date of the time the message was sent"
  161. }
  162. });
  163. Schemas.Alert = new SimpleSchema({
  164. description: {
  165. type: String,
  166. label: "The Alert's Description"
  167. },
  168. active: {
  169. type: Boolean,
  170. label: "Whether or not the alert is active or not"
  171. },
  172. createdBy: {
  173. type: String,
  174. label: "Username of the person who created an alert"
  175. }
  176. });
  177. Schemas.Feedback = new SimpleSchema({
  178. username: {
  179. type: String,
  180. label: "Username of user who submitted feedback"
  181. },
  182. message: {
  183. type: String,
  184. label: "Feedback message"
  185. },
  186. upvotes: {
  187. type: Number,
  188. label: "Number of upvotes for a feedback"
  189. },
  190. upvotedBy: {
  191. type: Array,
  192. label: "Array of usernames of users who upvoted a feedback"
  193. },
  194. "upvotedBy.$": {
  195. type: String,
  196. label: "Username of user who upvoted a feedback"
  197. }
  198. });
  199. Schemas.Room = new SimpleSchema({
  200. display: {
  201. type: String,
  202. label: "Room Display Name",
  203. regEx: /^[a-z0-9A-Z_\s]{1,30}$/
  204. },
  205. type: {
  206. type: String,
  207. label: "Room Type",
  208. regEx: /^[a-z0-9_]{1,20}$/
  209. },
  210. currentSong: {
  211. type: Object,
  212. defaultValue: {},
  213. label: "Current Song"
  214. },
  215. "currentSong.song": {
  216. type: Schemas.FullSong,
  217. label: "Current Song Object"
  218. },
  219. "currentSong.started": {
  220. type: Number,
  221. label: "Current Song Start Date"
  222. },
  223. timePaused: {
  224. type: Number,
  225. defaultValue: 0,
  226. label: "Amount of time a room has been paused for"
  227. },
  228. users: {
  229. type: Number,
  230. defaultValue: 0,
  231. label: "Users Online",
  232. min: 0
  233. },
  234. state: {
  235. type: String,
  236. defaultValue: "paused",
  237. allowedValues: ["paused", "playing"],
  238. label: "Room State"
  239. },
  240. votes: {
  241. type: Number,
  242. defaultValue: 0,
  243. label: "Current votes to skip current song",
  244. min: 0
  245. },
  246. private: {
  247. type: Boolean,
  248. defaultValue: false,
  249. label: "Room private or not"
  250. },
  251. roomDesc: {
  252. type: String,
  253. label: "Room description"
  254. },
  255. userList: {
  256. type: Array,
  257. label: "List of currently online people",
  258. defaultValue: []
  259. },
  260. "userList.$": {
  261. type: String,
  262. label: "Username of user currently in a room"
  263. },
  264. "playlist": {
  265. type: String,
  266. optional: true,
  267. label: "Name of current playlist selected from owner"
  268. }
  269. });
  270. Schemas.PrivateRoom = new SimpleSchema({
  271. name: {
  272. type: String,
  273. label: "Room Name",
  274. regEx: /^[a-z0-9A-Z_\s]{1,30}$/
  275. },
  276. displayName: {
  277. type: String,
  278. label: "Room Display Name"
  279. },
  280. currentSong: {
  281. type: Object,
  282. defaultValue: {song: {id: "60ItHLz5WEA", duration: 213, title: "Alan Walker - Faded"}, started: 0},
  283. label: "Current Song Object"
  284. },
  285. "currentSong.song": {
  286. type: Schemas.UserSong,
  287. label: "Current Song Object"
  288. },
  289. "currentSong.started": {
  290. type: Number,
  291. label: "Current Song Start Date"
  292. },
  293. timePaused: {
  294. type: Number,
  295. defaultValue: 0,
  296. label: "Amount of time a room has been paused for"
  297. },
  298. users: {
  299. type: Number,
  300. defaultValue: 0,
  301. label: "Users Online",
  302. min: 0
  303. },
  304. state: {
  305. type: String,
  306. defaultValue: "playing",
  307. allowedValues: ["paused", "playing"],
  308. label: "Room State"
  309. },
  310. votes: {
  311. type: Number,
  312. defaultValue: 0,
  313. label: "Current votes to skip current song",
  314. min: 0
  315. },
  316. privacy: {
  317. type: String,
  318. defaultValue: "private",
  319. label: "Room privacy",
  320. allowedValues: ["public", "unlisted", "private"]
  321. },
  322. roomDesc: {
  323. type: String,
  324. label: "Room description"
  325. },
  326. userList: {
  327. type: Array,
  328. label: "List of currently online people",
  329. defaultValue: []
  330. },
  331. "userList.$": {
  332. type: String,
  333. label: "Username of user currently in a room"
  334. },
  335. allowed: {
  336. type: Array,
  337. label: "List of allowed users in the room",
  338. defaultValue: []
  339. },
  340. "allowed.$": {
  341. type: String,
  342. label: "Username of user allowed in room"
  343. },
  344. "playlist": {
  345. type: String,
  346. optional: true,
  347. label: "Playlist in room"
  348. },
  349. "owner": {
  350. type: String,
  351. label: "User id of owner"
  352. },
  353. lastSong: {
  354. type: Number,
  355. label: "Index of the previous song",
  356. defaultValue: 0
  357. }
  358. });
  359. Schemas.PrivatePlaylist = new SimpleSchema({
  360. name: {
  361. type: String,
  362. label: "Name of playlist",
  363. regEx: /^[a-z0-9_]{1,20}$/
  364. },
  365. displayName: {
  366. type: String,
  367. label: "Displayname of playlist"
  368. },
  369. songs: {
  370. type: Array,
  371. label: "Array of song objects"
  372. },
  373. "songs.$": {
  374. type: Schemas.UserSong,
  375. label: "Song Object"
  376. },
  377. owner: {
  378. type: String,
  379. label: "Owner of playlist"
  380. }
  381. });
  382. Schemas.Playlist = new SimpleSchema({
  383. type: {
  384. type: String,
  385. label: "Type of the room the playlist is for",
  386. regEx: /^[a-z0-9_]{1,20}$/
  387. },
  388. songs: {
  389. type: Array,
  390. label: "Array of song MID's"
  391. },
  392. "songs.$": {
  393. type: String,
  394. label: "Song mid"
  395. },
  396. lastSong: {
  397. type: Number,
  398. label: "Index of the previous song",
  399. defaultValue: 0
  400. }
  401. });
  402. Schemas.UserProfile = new SimpleSchema({
  403. username: {
  404. type: String,
  405. label: "Username",
  406. regEx: /^[a-zA-Z0-9_]+$/,
  407. min: 3,
  408. max: 26
  409. },
  410. usernameL: {
  411. type: String,
  412. label: "Username in lowercase",
  413. regEx: /^[a-z0-9_]+$/
  414. },
  415. realname: {
  416. type: String,
  417. label: "Real Name",
  418. regEx: /^[A-Za-z0-9 .'-]+$/,
  419. optional: true
  420. },
  421. rank: {
  422. type: String,
  423. label: "Rank",
  424. allowedValues: ["default", "moderator", "admin"]
  425. },
  426. liked: {
  427. type: Array,
  428. label: "User's Liked songs"
  429. },
  430. "liked.$": {
  431. type: String,
  432. label: "A MID of a song a user liked"
  433. },
  434. disliked: {
  435. type: Array,
  436. label: "User's Disliked songs"
  437. },
  438. "disliked.$": {
  439. type: String,
  440. label: "A MID of a song a user disliked"
  441. },
  442. settings: {
  443. type: Object,
  444. label: "The settings of a user"
  445. },
  446. "settings.showRating": {
  447. type: Boolean,
  448. label: "If a user wants their liked and disliked songs to show up for everyone",
  449. defaultValue: false
  450. },
  451. statistics: {
  452. type: Object,
  453. label: "The statistics of a user"
  454. },
  455. "statistics.songsRequested": {
  456. type: Number,
  457. label: "Amount of songs the user has requested",
  458. defaultValue: 0
  459. }
  460. });
  461. Schemas.UserPunishments = new SimpleSchema({
  462. mute: {
  463. type: Object,
  464. label: "User's Current Mute Info",
  465. optional: true
  466. },
  467. "mute.mutedBy": {
  468. type: String,
  469. label: "Muted By"
  470. },
  471. "mute.mutedAt": {
  472. type: Date,
  473. label: "Muted At"
  474. },
  475. "mute.mutedUntil": {
  476. type: Date,
  477. label: "Muted Until"
  478. },
  479. mutes: {
  480. type: Array,
  481. label: "All of the mutes of a user",
  482. optional: true
  483. },
  484. "mutes.$": {
  485. type: Object,
  486. label: "One of the mutes of a user"
  487. },
  488. "mutes.$.mutedBy": {
  489. type: String,
  490. label: "Muted By"
  491. },
  492. "mutes.$.mutedAt": {
  493. type: Date,
  494. label: "Muted At"
  495. },
  496. "mutes.$.mutedUntil": {
  497. type: Date,
  498. label: "Muted Until"
  499. },
  500. ban: {
  501. type: Object,
  502. label: "User's Current Ban Info",
  503. optional: true
  504. },
  505. "ban.bannedBy": {
  506. type: String,
  507. label: "Banned By"
  508. },
  509. "ban.bannedReason": {
  510. type: String,
  511. label: "Banned Reason"
  512. },
  513. "ban.bannedAt": {
  514. type: Date,
  515. label: "Banned At"
  516. },
  517. "ban.bannedUntil": {
  518. type: Date,
  519. label: "Banned Until"
  520. },
  521. bans: {
  522. type: Array,
  523. label: "All of the bans of a user",
  524. optional: true
  525. },
  526. "bans.$": {
  527. type: Object,
  528. label: "One of the bans of a user"
  529. },
  530. "bans.$.bannedBy": {
  531. type: String,
  532. label: "Banned By"
  533. },
  534. "bans.$.bannedReason": {
  535. type: String,
  536. label: "Banned Reason"
  537. },
  538. "bans.$.bannedAt": {
  539. type: Date,
  540. label: "Banned At"
  541. },
  542. "bans.$.bannedUntil": {
  543. type: Date,
  544. label: "Banned Until"
  545. }
  546. });
  547. Schemas.User = new SimpleSchema({
  548. username: {
  549. type: String,
  550. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  551. // optional here because the accounts-password package does its own validation.
  552. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  553. optional: true,
  554. regEx: /^[a-zA-Z0-9_]+$/,
  555. min: 3,
  556. max: 26
  557. },
  558. emails: {
  559. type: Array,
  560. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  561. // optional here because the accounts-password package does its own validation.
  562. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  563. optional: true
  564. },
  565. "emails.$": {
  566. type: Object
  567. },
  568. "emails.$.address": {
  569. type: String,
  570. regEx: SimpleSchema.RegEx.Email
  571. },
  572. "emails.$.verified": {
  573. type: Boolean
  574. },
  575. createdAt: {
  576. type: Date
  577. },
  578. profile: {
  579. type: Schemas.UserProfile
  580. },
  581. punishments: {
  582. type: Schemas.UserPunishments,
  583. defaultValue: {mutes: [], bans: []}
  584. },
  585. // Make sure this services field is in your schema if you're using any of the accounts packages
  586. services: {
  587. type: Object,
  588. optional: true,
  589. blackbox: true
  590. },
  591. // In order to avoid an 'Exception in setInterval callback' from Meteor
  592. heartbeat: {
  593. type: Date,
  594. optional: true
  595. }
  596. });
  597. Schemas.Report = new SimpleSchema({
  598. room: {
  599. type: String,
  600. label: "Type of the room that the reports are from",
  601. regEx: /^[a-z0-9_]{1,20}$/
  602. },
  603. report: {
  604. type: Array,
  605. label: "The reports"
  606. },
  607. "report.$": {
  608. type: Object,
  609. label: "A report"
  610. },
  611. "report.$.song": {
  612. type: String,
  613. label: "A report's song MID"
  614. },
  615. "report.$.type": {
  616. type: Array,
  617. label: "The types of things a song was reported for"
  618. },
  619. "report.$.type.$": {
  620. type: String,
  621. label: "A type of thing a report was reported for",
  622. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  623. },
  624. "report.$.reason": {
  625. type: Array,
  626. label: "The reasons a song was reported for"
  627. },
  628. "report.$.reason.$": {
  629. type: String,
  630. label: "A reason a song was reported for",
  631. 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"]
  632. },
  633. "report.$.other": {
  634. type: String,
  635. label: "Other",
  636. optional: true
  637. }
  638. });
  639. Schemas.Article = new SimpleSchema({
  640. "title": {
  641. type: String,
  642. label: "Article Title"
  643. },
  644. "content": {
  645. type: String,
  646. label: "Article Content"
  647. },
  648. "author": {
  649. type: String,
  650. label: "Article's Author"
  651. },
  652. "time": {
  653. type: Date,
  654. label: "Article's Create Date"
  655. }
  656. });
  657. Rooms.attachSchema(Schemas.Room);
  658. Alerts.attachSchema(Schemas.Alert);
  659. Chat.attachSchema(Schemas.Chat);
  660. Playlists.attachSchema(Schemas.Playlist);
  661. Queues.attachSchema(Schemas.QueueSong);
  662. Meteor.users.attachSchema(Schemas.User);
  663. Reports.attachSchema(Schemas.Report);
  664. Feedback.attachSchema(Schemas.Feedback);
  665. Songs.attachSchema(Schemas.FullSong);
  666. News.attachSchema(Schemas.Article);
  667. PrivateRooms.attachSchema(Schemas.PrivateRoom);
  668. PrivatePlaylists.attachSchema(Schemas.PrivatePlaylist);