schemas.js 16 KB

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