schemas.js 13 KB

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