schemas.js 17 KB

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