schemas.js 12 KB

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