schemas.js 17 KB

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