schemas.js 12 KB

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