schemas.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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.bannedAt": {
  373. type: Date,
  374. label: "Banned At"
  375. },
  376. "ban.bannedUntil": {
  377. type: Date,
  378. label: "Banned Until"
  379. },
  380. bans: {
  381. type: Array,
  382. label: "All of the bans of a user",
  383. optional: true
  384. },
  385. "bans.$": {
  386. type: Object,
  387. label: "One of the bans of a user"
  388. },
  389. "bans.$.bannedBy": {
  390. type: String,
  391. label: "Banned By"
  392. },
  393. "bans.$.bannedAt": {
  394. type: Date,
  395. label: "Banned At"
  396. },
  397. "bans.$.bannedUntil": {
  398. type: Date,
  399. label: "Banned Until"
  400. }
  401. });
  402. Schemas.User = new SimpleSchema({
  403. username: {
  404. type: String,
  405. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  406. // optional here because the accounts-password package does its own validation.
  407. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  408. optional: true,
  409. regEx: /^[a-zA-Z0-9_]+$/,
  410. min: 6,
  411. max: 26
  412. },
  413. emails: {
  414. type: Array,
  415. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  416. // optional here because the accounts-password package does its own validation.
  417. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  418. optional: true
  419. },
  420. "emails.$": {
  421. type: Object
  422. },
  423. "emails.$.address": {
  424. type: String,
  425. regEx: SimpleSchema.RegEx.Email
  426. },
  427. "emails.$.verified": {
  428. type: Boolean
  429. },
  430. createdAt: {
  431. type: Date
  432. },
  433. profile: {
  434. type: Schemas.UserProfile
  435. },
  436. punishments: {
  437. type: Schemas.UserPunishments,
  438. defaultValue: {mutes: [], bans: []}
  439. },
  440. // Make sure this services field is in your schema if you're using any of the accounts packages
  441. services: {
  442. type: Object,
  443. optional: true,
  444. blackbox: true
  445. },
  446. // In order to avoid an 'Exception in setInterval callback' from Meteor
  447. heartbeat: {
  448. type: Date,
  449. optional: true
  450. }
  451. });
  452. Schemas.Report = new SimpleSchema({
  453. room: {
  454. type: String,
  455. label: "Type of the room that the reports are from",
  456. regEx: /^[a-z0-9_]{1,20}$/
  457. },
  458. report: {
  459. type: Array,
  460. label: "The reports"
  461. },
  462. "report.$": {
  463. type: Object,
  464. label: "A report"
  465. },
  466. "report.$.song": {
  467. type: String,
  468. label: "A report's song MID"
  469. },
  470. "report.$.type": {
  471. type: Array,
  472. label: "The types of things a song was reported for"
  473. },
  474. "report.$.type.$": {
  475. type: String,
  476. label: "A type of thing a report was reported for",
  477. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  478. },
  479. "report.$.reason": {
  480. type: Array,
  481. label: "The reasons a song was reported for"
  482. },
  483. "report.$.reason.$": {
  484. type: String,
  485. label: "A reason a song was reported for",
  486. 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"]
  487. },
  488. "report.$.other": {
  489. type: String,
  490. label: "Other",
  491. optional: true
  492. }
  493. });
  494. Rooms.attachSchema(Schemas.Room);
  495. Alerts.attachSchema(Schemas.Alert);
  496. Chat.attachSchema(Schemas.Chat);
  497. Playlists.attachSchema(Schemas.Playlist);
  498. Queues.attachSchema(Schemas.QueueSong);
  499. Meteor.users.attachSchema(Schemas.User);
  500. Reports.attachSchema(Schemas.Report);
  501. Feedback.attachSchema(Schemas.Feedback);
  502. Songs.attachSchema(Schemas.FullSong);