schemas.js 13 KB

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