schemas.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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. });
  225. Schemas.Playlist = new SimpleSchema({
  226. type: {
  227. type: String,
  228. label: "Type of the room the playlist is for",
  229. regEx: /^[a-z0-9_]{1,20}$/
  230. },
  231. songs: {
  232. type: Array,
  233. label: "All songs in that playlist"
  234. },
  235. "songs.$": {
  236. type: Schemas.FullSong,
  237. label: "Song object"
  238. },
  239. lastSong: {
  240. type: Number,
  241. label: "Index of the previous song",
  242. defaultValue: 0
  243. }
  244. });
  245. Schemas.Queue = 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: "All songs in that playlist"
  254. },
  255. "songs.$": {
  256. type: Schemas.QueueSong,
  257. label: "Song object"
  258. }
  259. });
  260. Schemas.UserProfile = new SimpleSchema({
  261. username: {
  262. type: String,
  263. label: "Username",
  264. regEx: /^[a-zA-Z0-9_]+$/,
  265. min: 4,
  266. max: 26
  267. },
  268. usernameL: {
  269. type: String,
  270. label: "Username in lowercase",
  271. regEx: /^[a-z0-9_]+$/
  272. },
  273. realname: {
  274. type: String,
  275. label: "Real Name",
  276. regEx: /^[A-Za-z0-9 .'-]+$/,
  277. optional: true
  278. },
  279. rank: {
  280. type: String,
  281. label: "Rank",
  282. allowedValues: ["default", "moderator", "admin"]
  283. },
  284. liked: {
  285. type: Array,
  286. label: "User's Liked songs"
  287. },
  288. "liked.$": {
  289. type: String,
  290. label: "A MID of a song a user liked"
  291. },
  292. disliked: {
  293. type: Array,
  294. label: "User's Disliked songs"
  295. },
  296. "disliked.$": {
  297. type: String,
  298. label: "A MID of a song a user disliked"
  299. },
  300. settings: {
  301. type: Object,
  302. label: "The settings of a user"
  303. },
  304. "settings.showRating": {
  305. type: Boolean,
  306. label: "If a user wants their liked and disliked songs to show up for everyone",
  307. defaultValue: false
  308. },
  309. statistics: {
  310. type: Object,
  311. label: "The statistics of a user"
  312. },
  313. "statistics.songsRequested": {
  314. type: Number,
  315. label: "Amount of songs the user has requested",
  316. defaultValue: 0
  317. }
  318. });
  319. Schemas.UserPunishments = new SimpleSchema({
  320. mute: {
  321. type: Object,
  322. label: "User's Current Mute Info",
  323. optional: true
  324. },
  325. "mute.mutedBy": {
  326. type: String,
  327. label: "Muted By"
  328. },
  329. "mute.mutedAt": {
  330. type: Date,
  331. label: "Muted At"
  332. },
  333. "mute.mutedUntil": {
  334. type: Date,
  335. label: "Muted Until"
  336. },
  337. mutes: {
  338. type: Array,
  339. label: "All of the mutes of a user",
  340. optional: true
  341. },
  342. "mutes.$": {
  343. type: Object,
  344. label: "One of the mutes of a user"
  345. },
  346. "mutes.$.mutedBy": {
  347. type: String,
  348. label: "Muted By"
  349. },
  350. "mutes.$.mutedAt": {
  351. type: Date,
  352. label: "Muted At"
  353. },
  354. "mutes.$.mutedUntil": {
  355. type: Date,
  356. label: "Muted Until"
  357. },
  358. ban: {
  359. type: Object,
  360. label: "User's Current Ban Info",
  361. optional: true
  362. },
  363. "ban.bannedBy": {
  364. type: String,
  365. label: "Banned By"
  366. },
  367. "ban.bannedAt": {
  368. type: Date,
  369. label: "Banned At"
  370. },
  371. "ban.bannedUntil": {
  372. type: Date,
  373. label: "Banned Until"
  374. },
  375. bans: {
  376. type: Array,
  377. label: "All of the bans of a user",
  378. optional: true
  379. },
  380. "bans.$": {
  381. type: Object,
  382. label: "One of the bans of a user"
  383. },
  384. "bans.$.bannedBy": {
  385. type: String,
  386. label: "Banned By"
  387. },
  388. "bans.$.bannedAt": {
  389. type: Date,
  390. label: "Banned At"
  391. },
  392. "bans.$.bannedUntil": {
  393. type: Date,
  394. label: "Banned Until"
  395. }
  396. });
  397. Schemas.User = new SimpleSchema({
  398. username: {
  399. type: String,
  400. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  401. // optional here because the accounts-password package does its own validation.
  402. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  403. optional: true,
  404. regEx: /^[a-zA-Z0-9_]+$/,
  405. min: 6,
  406. max: 26
  407. },
  408. emails: {
  409. type: Array,
  410. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  411. // optional here because the accounts-password package does its own validation.
  412. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  413. optional: true
  414. },
  415. "emails.$": {
  416. type: Object
  417. },
  418. "emails.$.address": {
  419. type: String,
  420. regEx: SimpleSchema.RegEx.Email
  421. },
  422. "emails.$.verified": {
  423. type: Boolean
  424. },
  425. createdAt: {
  426. type: Date
  427. },
  428. profile: {
  429. type: Schemas.UserProfile
  430. },
  431. punishments: {
  432. type: Schemas.UserPunishments,
  433. defaultValue: {mutes: [], bans: []}
  434. },
  435. // Make sure this services field is in your schema if you're using any of the accounts packages
  436. services: {
  437. type: Object,
  438. optional: true,
  439. blackbox: true
  440. },
  441. // In order to avoid an 'Exception in setInterval callback' from Meteor
  442. heartbeat: {
  443. type: Date,
  444. optional: true
  445. }
  446. });
  447. Schemas.Report = new SimpleSchema({
  448. room: {
  449. type: String,
  450. label: "Type of the room that the reports are from",
  451. regEx: /^[a-z0-9_]{1,20}$/
  452. },
  453. report: {
  454. type: Array,
  455. label: "The reports"
  456. },
  457. "report.$": {
  458. type: Object,
  459. label: "A report"
  460. },
  461. "report.$.song": {
  462. type: String,
  463. label: "A report's song MID"
  464. },
  465. "report.$.type": {
  466. type: Array,
  467. label: "The types of things a song was reported for"
  468. },
  469. "report.$.type.$": {
  470. type: String,
  471. label: "A type of thing a report was reported for",
  472. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  473. },
  474. "report.$.reason": {
  475. type: Array,
  476. label: "The reasons a song was reported for"
  477. },
  478. "report.$.reason.$": {
  479. type: String,
  480. label: "A reason a song was reported for",
  481. 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"]
  482. },
  483. "report.$.other": {
  484. type: String,
  485. label: "Other",
  486. optional: true
  487. }
  488. });
  489. Rooms.attachSchema(Schemas.Room);
  490. Alerts.attachSchema(Schemas.Alert);
  491. Chat.attachSchema(Schemas.Chat);
  492. Playlists.attachSchema(Schemas.Playlist);
  493. Queues.attachSchema(Schemas.Queue);
  494. Meteor.users.attachSchema(Schemas.User);
  495. Reports.attachSchema(Schemas.Report);
  496. Feedback.attachSchema(Schemas.Feedback);