schemas.js 12 KB

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