schemas.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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. active: {
  153. type: Boolean,
  154. label: "Whether or not the alert is active or not"
  155. },
  156. createdBy: {
  157. type: String,
  158. label: "Username of the person who created an alert"
  159. }
  160. });
  161. Schemas.Feedback = new SimpleSchema({
  162. username: {
  163. type: String,
  164. label: "Username of user who submitted feedback"
  165. },
  166. message: {
  167. type: String,
  168. label: "Feedback message"
  169. },
  170. upvotes: {
  171. type: Number,
  172. label: "Number of upvotes for a feedback"
  173. },
  174. upvotedBy: {
  175. type: Array,
  176. label: "Array of usernames of users who upvoted a feedback"
  177. },
  178. "upvotedBy.$": {
  179. type: String,
  180. label: "Username of user who upvoted a feedback"
  181. }
  182. });
  183. Schemas.Room = new SimpleSchema({
  184. display: {
  185. type: String,
  186. label: "Room Display Name",
  187. regEx: /^[a-z0-9A-Z_\s]{1,30}$/
  188. },
  189. type: {
  190. type: String,
  191. label: "Room Type",
  192. regEx: /^[a-z0-9_]{1,20}$/
  193. },
  194. currentSong: {
  195. type: Object,
  196. defaultValue: {},
  197. label: "Current Song"
  198. },
  199. "currentSong.song": {
  200. type: Schemas.FullSong,
  201. label: "Current Song Object"
  202. },
  203. "currentSong.started": {
  204. type: Number,
  205. label: "Current Song Start Date"
  206. },
  207. timePaused: {
  208. type: Number,
  209. defaultValue: 0,
  210. label: "Amount of time a room has been paused for"
  211. },
  212. users: {
  213. type: Number,
  214. defaultValue: 0,
  215. label: "Users Online",
  216. min: 0
  217. },
  218. state: {
  219. type: String,
  220. defaultValue: "paused",
  221. allowedValues: ["paused", "playing"],
  222. label: "Room State"
  223. },
  224. votes: {
  225. type: Number,
  226. defaultValue: 0,
  227. label: "Current votes to skip current song",
  228. min: 0
  229. },
  230. private: {
  231. type: Boolean,
  232. defaultValue: false,
  233. label: "Room private or not"
  234. },
  235. roomDesc: {
  236. type: String,
  237. label: "Room description"
  238. }
  239. });
  240. Schemas.Playlist = new SimpleSchema({
  241. type: {
  242. type: String,
  243. label: "Type of the room the playlist is for",
  244. regEx: /^[a-z0-9_]{1,20}$/
  245. },
  246. songs: {
  247. type: Array,
  248. label: "Array of song MID's"
  249. },
  250. "songs.$": {
  251. type: String,
  252. label: "Song mid"
  253. },
  254. lastSong: {
  255. type: Number,
  256. label: "Index of the previous song",
  257. defaultValue: 0
  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.bannedReason": {
  368. type: String,
  369. label: "Banned Reason"
  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.$.bannedReason": {
  393. type: String,
  394. label: "Banned Reason"
  395. },
  396. "bans.$.bannedAt": {
  397. type: Date,
  398. label: "Banned At"
  399. },
  400. "bans.$.bannedUntil": {
  401. type: Date,
  402. label: "Banned Until"
  403. }
  404. });
  405. Schemas.User = new SimpleSchema({
  406. username: {
  407. type: String,
  408. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  409. // optional here because the accounts-password package does its own validation.
  410. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  411. optional: true,
  412. regEx: /^[a-zA-Z0-9_]+$/,
  413. min: 6,
  414. max: 26
  415. },
  416. emails: {
  417. type: Array,
  418. // For accounts-password, either emails or username is required, but not both. It is OK to make this
  419. // optional here because the accounts-password package does its own validation.
  420. // Third-party login packages may not require either. Adjust this schema as necessary for your usage.
  421. optional: true
  422. },
  423. "emails.$": {
  424. type: Object
  425. },
  426. "emails.$.address": {
  427. type: String,
  428. regEx: SimpleSchema.RegEx.Email
  429. },
  430. "emails.$.verified": {
  431. type: Boolean
  432. },
  433. createdAt: {
  434. type: Date
  435. },
  436. profile: {
  437. type: Schemas.UserProfile
  438. },
  439. punishments: {
  440. type: Schemas.UserPunishments,
  441. defaultValue: {mutes: [], bans: []}
  442. },
  443. // Make sure this services field is in your schema if you're using any of the accounts packages
  444. services: {
  445. type: Object,
  446. optional: true,
  447. blackbox: true
  448. },
  449. // In order to avoid an 'Exception in setInterval callback' from Meteor
  450. heartbeat: {
  451. type: Date,
  452. optional: true
  453. }
  454. });
  455. Schemas.Report = new SimpleSchema({
  456. room: {
  457. type: String,
  458. label: "Type of the room that the reports are from",
  459. regEx: /^[a-z0-9_]{1,20}$/
  460. },
  461. report: {
  462. type: Array,
  463. label: "The reports"
  464. },
  465. "report.$": {
  466. type: Object,
  467. label: "A report"
  468. },
  469. "report.$.song": {
  470. type: String,
  471. label: "A report's song MID"
  472. },
  473. "report.$.type": {
  474. type: Array,
  475. label: "The types of things a song was reported for"
  476. },
  477. "report.$.type.$": {
  478. type: String,
  479. label: "A type of thing a report was reported for",
  480. allowedValues: ["report-song", "report-title", "report-author", "report-duration", "report-audio", "report-albumart", "report-other"]
  481. },
  482. "report.$.reason": {
  483. type: Array,
  484. label: "The reasons a song was reported for"
  485. },
  486. "report.$.reason.$": {
  487. type: String,
  488. label: "A reason a song was reported for",
  489. 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"]
  490. },
  491. "report.$.other": {
  492. type: String,
  493. label: "Other",
  494. optional: true
  495. }
  496. });
  497. Schemas.Article = new SimpleSchema({
  498. "title": {
  499. type: String,
  500. label: "Article Title"
  501. },
  502. "content": {
  503. type: String,
  504. label: "Article Content"
  505. },
  506. "author": {
  507. type: String,
  508. label: "Article's Author"
  509. },
  510. "time": {
  511. type: Date,
  512. label: "Article's Create Date"
  513. }
  514. });
  515. Rooms.attachSchema(Schemas.Room);
  516. Alerts.attachSchema(Schemas.Alert);
  517. Chat.attachSchema(Schemas.Chat);
  518. Playlists.attachSchema(Schemas.Playlist);
  519. Queues.attachSchema(Schemas.QueueSong);
  520. Meteor.users.attachSchema(Schemas.User);
  521. Reports.attachSchema(Schemas.Report);
  522. Feedback.attachSchema(Schemas.Feedback);
  523. Songs.attachSchema(Schemas.FullSong);
  524. News.attachSchema(Schemas.Article);