schemas.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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: "paused",
  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. private: {
  317. type: Boolean,
  318. defaultValue: false,
  319. label: "Room private or not"
  320. },
  321. roomDesc: {
  322. type: String,
  323. label: "Room description"
  324. },
  325. userList: {
  326. type: Array,
  327. label: "List of currently online people",
  328. defaultValue: []
  329. },
  330. "userList.$": {
  331. type: String,
  332. label: "Username of user currently in a room"
  333. },
  334. allowed: {
  335. type: Array,
  336. label: "List of allowed users in the room",
  337. defaultValue: []
  338. },
  339. "allowed.$": {
  340. type: String,
  341. label: "Username of user allowed in room"
  342. },
  343. "playlist": {
  344. type: String,
  345. optional: true,
  346. label: "Playlist in room"
  347. },
  348. "owner": {
  349. type: String,
  350. label: "Username of owner"
  351. },
  352. lastSong: {
  353. type: Number,
  354. label: "Index of the previous song",
  355. defaultValue: 0
  356. }
  357. });
  358. Schemas.PrivatePlaylist = new SimpleSchema({
  359. name: {
  360. type: String,
  361. label: "Name of playlist",
  362. regEx: /^[a-z0-9_]{1,20}$/
  363. },
  364. displayName: {
  365. type: String,
  366. label: "Displayname of playlist"
  367. },
  368. songs: {
  369. type: Array,
  370. label: "Array of song objects"
  371. },
  372. "songs.$": {
  373. type: Schemas.UserSong,
  374. label: "Song Object"
  375. },
  376. owner: {
  377. type: String,
  378. label: "Owner of playlist"
  379. }
  380. });
  381. Schemas.Playlist = new SimpleSchema({
  382. type: {
  383. type: String,
  384. label: "Type of the room the playlist is for",
  385. regEx: /^[a-z0-9_]{1,20}$/
  386. },
  387. songs: {
  388. type: Array,
  389. label: "Array of song MID's"
  390. },
  391. "songs.$": {
  392. type: String,
  393. label: "Song mid"
  394. },
  395. lastSong: {
  396. type: Number,
  397. label: "Index of the previous song",
  398. defaultValue: 0
  399. }
  400. });
  401. Schemas.UserProfile = new SimpleSchema({
  402. username: {
  403. type: String,
  404. label: "Username",
  405. regEx: /^[a-zA-Z0-9_]+$/,
  406. min: 3,
  407. max: 26
  408. },
  409. usernameL: {
  410. type: String,
  411. label: "Username in lowercase",
  412. regEx: /^[a-z0-9_]+$/
  413. },
  414. realname: {
  415. type: String,
  416. label: "Real Name",
  417. regEx: /^[A-Za-z0-9 .'-]+$/,
  418. optional: true
  419. },
  420. rank: {
  421. type: String,
  422. label: "Rank",
  423. allowedValues: ["default", "moderator", "admin"]
  424. },
  425. liked: {
  426. type: Array,
  427. label: "User's Liked songs"
  428. },
  429. "liked.$": {
  430. type: String,
  431. label: "A MID of a song a user liked"
  432. },
  433. disliked: {
  434. type: Array,
  435. label: "User's Disliked songs"
  436. },
  437. "disliked.$": {
  438. type: String,
  439. label: "A MID of a song a user disliked"
  440. },
  441. settings: {
  442. type: Object,
  443. label: "The settings of a user"
  444. },
  445. "settings.showRating": {
  446. type: Boolean,
  447. label: "If a user wants their liked and disliked songs to show up for everyone",
  448. defaultValue: false
  449. },
  450. statistics: {
  451. type: Object,
  452. label: "The statistics of a user"
  453. },
  454. "statistics.songsRequested": {
  455. type: Number,
  456. label: "Amount of songs the user has requested",
  457. defaultValue: 0
  458. }
  459. });
  460. Schemas.UserPunishments = new SimpleSchema({
  461. mute: {
  462. type: Object,
  463. label: "User's Current Mute Info",
  464. optional: true
  465. },
  466. "mute.mutedBy": {
  467. type: String,
  468. label: "Muted By"
  469. },
  470. "mute.mutedAt": {
  471. type: Date,
  472. label: "Muted At"
  473. },
  474. "mute.mutedUntil": {
  475. type: Date,
  476. label: "Muted Until"
  477. },
  478. mutes: {
  479. type: Array,
  480. label: "All of the mutes of a user",
  481. optional: true
  482. },
  483. "mutes.$": {
  484. type: Object,
  485. label: "One of the mutes of a user"
  486. },
  487. "mutes.$.mutedBy": {
  488. type: String,
  489. label: "Muted By"
  490. },
  491. "mutes.$.mutedAt": {
  492. type: Date,
  493. label: "Muted At"
  494. },
  495. "mutes.$.mutedUntil": {
  496. type: Date,
  497. label: "Muted Until"
  498. },
  499. ban: {
  500. type: Object,
  501. label: "User's Current Ban Info",
  502. optional: true
  503. },
  504. "ban.bannedBy": {
  505. type: String,
  506. label: "Banned By"
  507. },
  508. "ban.bannedReason": {
  509. type: String,
  510. label: "Banned Reason"
  511. },
  512. "ban.bannedAt": {
  513. type: Date,
  514. label: "Banned At"
  515. },
  516. "ban.bannedUntil": {
  517. type: Date,
  518. label: "Banned Until"
  519. },
  520. bans: {
  521. type: Array,
  522. label: "All of the bans of a user",
  523. optional: true
  524. },
  525. "bans.$": {
  526. type: Object,
  527. label: "One of the bans of a user"
  528. },
  529. "bans.$.bannedBy": {
  530. type: String,
  531. label: "Banned By"
  532. },
  533. "bans.$.bannedReason": {
  534. type: String,
  535. label: "Banned Reason"
  536. },
  537. "bans.$.bannedAt": {
  538. type: Date,
  539. label: "Banned At"
  540. },
  541. "bans.$.bannedUntil": {
  542. type: Date,
  543. label: "Banned Until"
  544. }
  545. });
  546. Schemas.User = new SimpleSchema({
  547. username: {
  548. type: String,
  549. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  550. // optional here because the accounts-password package does its own validation.
  551. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  552. optional: true,
  553. regEx: /^[a-zA-Z0-9_]+$/,
  554. min: 3,
  555. max: 26
  556. },
  557. emails: {
  558. type: Array,
  559. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  560. // optional here because the accounts-password package does its own validation.
  561. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  562. optional: true
  563. },
  564. "emails.$": {
  565. type: Object
  566. },
  567. "emails.$.address": {
  568. type: String,
  569. regEx: SimpleSchema.RegEx.Email
  570. },
  571. "emails.$.verified": {
  572. type: Boolean
  573. },
  574. createdAt: {
  575. type: Date
  576. },
  577. profile: {
  578. type: Schemas.UserProfile
  579. },
  580. punishments: {
  581. type: Schemas.UserPunishments,
  582. defaultValue: {mutes: [], bans: []}
  583. },
  584. // Make sure this services field is in your schema if you're using any of the accounts packages
  585. services: {
  586. type: Object,
  587. optional: true,
  588. blackbox: true
  589. },
  590. // In order to avoid an 'Exception in setInterval callback' from Meteor
  591. heartbeat: {
  592. type: Date,
  593. optional: true
  594. }
  595. });
  596. Schemas.Report = new SimpleSchema({
  597. room: {
  598. type: String,
  599. label: "Type of the room that the reports are from",
  600. regEx: /^[a-z0-9_]{1,20}$/
  601. },
  602. report: {
  603. type: Array,
  604. label: "The reports"
  605. },
  606. "report.$": {
  607. type: Object,
  608. label: "A report"
  609. },
  610. "report.$.song": {
  611. type: String,
  612. label: "A report's song MID"
  613. },
  614. "report.$.type": {
  615. type: Array,
  616. label: "The types of things a song was reported for"
  617. },
  618. "report.$.type.$": {
  619. type: String,
  620. label: "A type of thing a report was reported for",
  621. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  622. },
  623. "report.$.reason": {
  624. type: Array,
  625. label: "The reasons a song was reported for"
  626. },
  627. "report.$.reason.$": {
  628. type: String,
  629. label: "A reason a song was reported for",
  630. 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"]
  631. },
  632. "report.$.other": {
  633. type: String,
  634. label: "Other",
  635. optional: true
  636. }
  637. });
  638. Schemas.Article = new SimpleSchema({
  639. "title": {
  640. type: String,
  641. label: "Article Title"
  642. },
  643. "content": {
  644. type: String,
  645. label: "Article Content"
  646. },
  647. "author": {
  648. type: String,
  649. label: "Article's Author"
  650. },
  651. "time": {
  652. type: Date,
  653. label: "Article's Create Date"
  654. }
  655. });
  656. Rooms.attachSchema(Schemas.Room);
  657. Alerts.attachSchema(Schemas.Alert);
  658. Chat.attachSchema(Schemas.Chat);
  659. Playlists.attachSchema(Schemas.Playlist);
  660. Queues.attachSchema(Schemas.QueueSong);
  661. Meteor.users.attachSchema(Schemas.User);
  662. Reports.attachSchema(Schemas.Report);
  663. Feedback.attachSchema(Schemas.Feedback);
  664. Songs.attachSchema(Schemas.FullSong);
  665. News.attachSchema(Schemas.Article);
  666. PrivateRooms.attachSchema(Schemas.PrivateRoom);
  667. PrivatePlaylists.attachSchema(Schemas.PrivatePlaylist);