schemas.js 12 KB

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