schemas.js 11 KB

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