logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

mrf_transparency_panel.js (3077B)


  1. import { mapState } from 'vuex'
  2. import { get } from 'lodash'
  3. /**
  4. * This is for backwards compatibility. We originally didn't recieve
  5. * extra info like a reason why an instance was rejected/quarantined/etc.
  6. * Because we didn't want to break backwards compatibility it was decided
  7. * to add an extra "info" key.
  8. */
  9. const toInstanceReasonObject = (instances, info, key) => {
  10. return instances.map(instance => {
  11. if (info[key] && info[key][instance] && info[key][instance].reason) {
  12. return { instance, reason: info[key][instance].reason }
  13. }
  14. return { instance, reason: '' }
  15. })
  16. }
  17. const MRFTransparencyPanel = {
  18. computed: {
  19. ...mapState({
  20. federationPolicy: state => get(state, 'instance.federationPolicy'),
  21. mrfPolicies: state => get(state, 'instance.federationPolicy.mrf_policies', []),
  22. quarantineInstances: state => toInstanceReasonObject(
  23. get(state, 'instance.federationPolicy.quarantined_instances', []),
  24. get(state, 'instance.federationPolicy.quarantined_instances_info', []),
  25. 'quarantined_instances'
  26. ),
  27. acceptInstances: state => toInstanceReasonObject(
  28. get(state, 'instance.federationPolicy.mrf_simple.accept', []),
  29. get(state, 'instance.federationPolicy.mrf_simple_info', []),
  30. 'accept'
  31. ),
  32. rejectInstances: state => toInstanceReasonObject(
  33. get(state, 'instance.federationPolicy.mrf_simple.reject', []),
  34. get(state, 'instance.federationPolicy.mrf_simple_info', []),
  35. 'reject'
  36. ),
  37. ftlRemovalInstances: state => toInstanceReasonObject(
  38. get(state, 'instance.federationPolicy.mrf_simple.federated_timeline_removal', []),
  39. get(state, 'instance.federationPolicy.mrf_simple_info', []),
  40. 'federated_timeline_removal'
  41. ),
  42. mediaNsfwInstances: state => toInstanceReasonObject(
  43. get(state, 'instance.federationPolicy.mrf_simple.media_nsfw', []),
  44. get(state, 'instance.federationPolicy.mrf_simple_info', []),
  45. 'media_nsfw'
  46. ),
  47. mediaRemovalInstances: state => toInstanceReasonObject(
  48. get(state, 'instance.federationPolicy.mrf_simple.media_removal', []),
  49. get(state, 'instance.federationPolicy.mrf_simple_info', []),
  50. 'media_removal'
  51. ),
  52. keywordsFtlRemoval: state => get(state, 'instance.federationPolicy.mrf_keyword.federated_timeline_removal', []),
  53. keywordsReject: state => get(state, 'instance.federationPolicy.mrf_keyword.reject', []),
  54. keywordsReplace: state => get(state, 'instance.federationPolicy.mrf_keyword.replace', [])
  55. }),
  56. hasInstanceSpecificPolicies () {
  57. return this.quarantineInstances.length ||
  58. this.acceptInstances.length ||
  59. this.rejectInstances.length ||
  60. this.ftlRemovalInstances.length ||
  61. this.mediaNsfwInstances.length ||
  62. this.mediaRemovalInstances.length
  63. },
  64. hasKeywordPolicies () {
  65. return this.keywordsFtlRemoval.length ||
  66. this.keywordsReject.length ||
  67. this.keywordsReplace.length
  68. }
  69. }
  70. }
  71. export default MRFTransparencyPanel