schemas.js 11 KB

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