diff --git a/js/dist/admin.js b/js/dist/admin.js index 89170bb..ba7bedd 100644 --- a/js/dist/admin.js +++ b/js/dist/admin.js @@ -1,2 +1,2 @@ -module.exports=function(t){var a={};function n(s){if(a[s])return a[s].exports;var e=a[s]={i:s,l:!1,exports:{}};return t[s].call(e.exports,e,e.exports,n),e.l=!0,e.exports}return n.m=t,n.c=a,n.d=function(t,a,s){n.o(t,a)||Object.defineProperty(t,a,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,a){if(1&a&&(t=n(t)),8&a)return t;if(4&a&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&a&&"string"!=typeof t)for(var e in t)n.d(s,e,function(a){return t[a]}.bind(null,e));return s},n.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(a,"a",a),a},n.o=function(t,a){return Object.prototype.hasOwnProperty.call(t,a)},n.p="",n(n.s=25)}([function(t,a){t.exports=flarum.core.compat.Model},function(t,a){t.exports=flarum.core.compat["components/Button"]},function(t,a,n){"use strict";function s(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,t.__proto__=a}n.d(a,"a",(function(){return s}))},function(t,a){t.exports=flarum.core.compat["components/Alert"]},function(t,a){t.exports=flarum.core.compat["helpers/punctuateSeries"]},function(t,a,n){"use strict";n.d(a,"a",(function(){return f}));var s=n(2),e=n(8),i=n.n(e),r=n(1),o=n.n(r),p=n(3),d=n.n(p),l=n(6),u=n.n(l),h=n(4),c=n.n(h),f=function(t){function a(){return t.apply(this,arguments)||this}Object(s.a)(a,t);var n=a.prototype;return n.oninit=function(a){if(t.prototype.oninit.call(this,a),this.address=this.attrs.address,this.post=this.attrs.post,this.user=this.attrs.user||this.post&&this.post.user(),!this.user&&this.address){var n=app.store.getBy("banned_ips","address",this.address);n&&(this.user=n.user())}this.banOptions=[],(this.post&&this.post.ipAddress()||this.address)&&this.banOptions.push("only"),this.user&&this.banOptions.push("all"),this.banOption=u()(this.banOptions[0]),this.reason=u()(""),this.otherUsers={},this.loading=!1},n.className=function(){return"Modal--medium"},n.title=function(){return app.translator.trans("fof-ban-ips.lib.modal.title")},n.content=function(){var t=this,a=this.otherUsers[this.banOption()],n=a&&a.map((function(t){return t&&t.displayName()||app.translator.trans("core.lib.username.deleted_text")}));return m("div",{className:"Modal-body"},m("p",null,app.translator.trans("fof-ban-ips.lib.modal.ban_ip_confirmation")),m("div",{className:"Form-group"},this.banOptions.map((function(a){return m("div",null,m("input",{type:"radio",name:"ban-option",id:"ban-option-"+a,checked:t.banOption()===a,onclick:t.banOption.bind(t,a)})," ",m("label",{htmlFor:"ban-option-"+a},app.translator.trans("fof-ban-ips.forum.modal.ban_options_"+a+"_ip",{user:t.user,ip:t.address||t.post&&t.post.ipAddress()})))}))),m("div",{className:"Form-group"},m("label",{className:"label"},app.translator.trans("fof-ban-ips.lib.modal.reason_label")),m("input",{type:"text",className:"FormControl",bidi:this.reason})),a?a.length?d.a.component({dismissible:!1},app.translator.transChoice("fof-ban-ips.lib.modal.ban_ip_users",n.length,{users:c()(n)})):d.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.forum.modal.ban_ip_no_users")):"",a&&m("br",null),m("div",{className:"Form-group"},m(o.a,{className:"Button Button--primary",type:"submit",loading:this.loading},n?app.translator.trans("fof-ban-ips.lib.modal.ban_button"):app.translator.trans("fof-ban-ips.lib.modal.check_button"))))},n.onsubmit=function(t){var a=this;if(t.preventDefault(),this.loading=!0,void 0===this.otherUsers[this.banOption()])return this.getOtherUsers();var n={reason:this.reason(),userId:this.user.id()};"only"===this.banOption()?(n.address=this.post.ipAddress(),app.store.createRecord("banned_ips").save(n).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this))):"all"===this.banOption()&&app.request({body:{data:{attributes:n}},url:""+app.forum.attribute("apiUrl")+this.user.apiEndpoint()+"/ban",method:"POST",errorHandler:this.onerror.bind(this)}).then((function(t){return app.store.pushPayload(t).forEach(a.done.bind(a))})).then(this.hide.bind(this)).catch((function(){})).then(this.loaded.bind(this))},n.getOtherUsers=function(){var t=this,a={};"only"===this.banOption()&&(a.ip=this.address||this.post.ipAddress()),app.request({params:a,url:app.forum.attribute("apiUrl")+"/fof/ban-ips/check-users/"+this.user.id(),method:"GET",errorHandler:this.onerror.bind(this)}).then((function(a){t.otherUsers[t.banOption()]=a.data.map((function(t){return app.store.pushObject(t)})).filter((function(t){return 0===t.bannedIPs().length})),t.loading=!1})).catch((function(){})).then(this.loaded.bind(this))},n.done=function(t){var a={type:"banned_ips",id:t.id()};this.post&&(this.post.data.relationships.banned_ip={data:a}),this.user.data.relationships.banned_ips||(this.user.data.relationships.banned_ips={data:[]}),this.user.data.relationships.banned_ips.data.push(a),this.user.data.attributes.isBanned=!0,app.store.pushObject(this.user.data)},a}(i.a)},function(t,a){t.exports=flarum.core.compat["utils/Stream"]},function(t,a,n){"use strict";n.d(a,"a",(function(){return l}));var s=n(2),e=n(1),i=n.n(e),r=n(3),o=n.n(r),p=n(4),d=n.n(p),l=(n(10),function(t){function a(){return t.apply(this,arguments)||this}Object(s.a)(a,t);var n=a.prototype;return n.title=function(){return app.translator.trans("fof-ban-ips.lib.modal.unban_title")},n.content=function(){var t=this,a=this.otherUsers[this.banOption()],n=a&&a.map((function(t){return t&&t.displayName()||app.translator.trans("core.lib.username.deleted_text")}));return this.bannedIPs?m("div",{className:"Modal-body"},o.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.lib.modal.unbanned_ips",{ips:d()(this.bannedIPs)}))):m("div",{className:"Modal-body"},m("p",null,app.translator.trans("fof-ban-ips.lib.modal.unban_ip_confirmation")),m("div",{className:"Form-group"},this.banOptions.map((function(a){return m("div",null,m("input",{type:"radio",name:"ban-option",id:"ban-option-"+a,checked:t.banOption()===a,onclick:t.banOption.bind(t,a)})," ",m("label",{htmlFor:"ban-option-"+a},app.translator.trans("fof-ban-ips.lib.modal.unban_options_"+a+"_ip",{user:t.user,ip:t.address||t.post&&t.post.ipAddress()})))}))),a?a.length?o.a.component({dismissible:!1},app.translator.transChoice("fof-ban-ips.lib.modal.unban_ip_users",n.length,{users:d()(n)})):o.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.lib.modal.unban_ip_no_users")):"",a&&m("br",null),m("div",{className:"Form-group"},m(i.a,{className:"Button Button--primary",type:"submit",loading:this.loading},n?app.translator.trans("fof-ban-ips.lib.modal.unban_button"):app.translator.trans("fof-ban-ips.lib.modal.check_button"))))},n.onsubmit=function(t){if(t.preventDefault(),this.loading=!0,void 0===this.otherUsers[this.banOption()])return this.getOtherUsers();var a={};if("only"===this.banOption()){a.address=this.address||this.post.ipAddress();var n=this.post?this.post.bannedIP():app.store.getBy("banned_ips","address",this.address);n.delete().then(this.done.bind(this,n)).catch(this.onerror.bind(this)).then(this.hide.bind(this))}else"all"===this.banOption()&&app.request({body:{data:{attributes:a}},url:""+app.forum.attribute("apiUrl")+this.user.apiEndpoint()+"/unban",method:"POST",errorHandler:this.onerror.bind(this)}).then(this.done.bind(this)).catch(this.onerror.bind(this)).then(this.hide.bind(this))},n.getOtherUsers=function(){var t=this,a={};"only"===this.banOption()&&(a.ip=this.address||this.post.ipAddress(),a.skipValidation=!0);var n=app.forum.attribute("apiUrl")+"/fof/ban-ips/check-users";this.user&&(n+="/"+this.user.id()),app.request({params:a,url:n,method:"GET",errorHandler:this.onerror.bind(this)}).then((function(a){var n=app.store.pushPayload(a);t.otherUsers[t.banOption()]=n.filter((function(t){return 1===t.bannedIPs().length})),t.loading=!1,m.redraw()})).catch((function(){})).then(this.loaded.bind(this))},n.done=function(t){this.loading=!1,this.post&&delete this.post.data.relationships.banned_ip,!this.user||this.user.data.relationships||t?this.user&&t instanceof app.store.models.banned_ips&&(this.user.data.relationships.banned_ips={data:this.user.data.relationships.banned_ips.data.filter((function(a){return a.id!==t.id()}))},this.user.data.attributes.isBanned=0!==this.user.data.relationships.banned_ips.data.length):(this.user.data.relationships.banned_ips.data=[],this.user.data.attributes.isBanned=!1),t&&Array.isArray(t.data)&&(this.bannedIPs=t.data.map((function(t){return t.attributes.address})),this.loading=!1,m.redraw())},n.hide=function(){t.prototype.hide.call(this),this.attrs.redraw||location.reload()},a}(n(5).a))},function(t,a){t.exports=flarum.core.compat["components/Modal"]},function(t,a,n){"use strict";n.d(a,"a",(function(){return o}));var s=n(2),e=n(0),i=n.n(e),r=n(13),o=function(t){function a(){return t.apply(this,arguments)||this}return Object(s.a)(a,t),a.prototype.apiEndpoint=function(){return"/fof/ban-ips"+(this.exists?"/"+this.id():"")},a}(n.n(r)()(i.a,{creator:i.a.hasOne("creator"),user:i.a.hasOne("user"),address:i.a.attribute("address"),reason:i.a.attribute("reason"),createdAt:i.a.attribute("createdAt",i.a.transformDate),deletedAt:i.a.attribute("deletedAt",i.a.transformDate)}))},function(t,a){t.exports=flarum.core.compat["helpers/username"]},function(t,a,n){"use strict";function s(){return(s=Object.assign||function(t){for(var a=1;a (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n
\n \n \n
\n\n {otherUsersBanned\n ? otherUsersBanned.length\n ? Alert.component({\n dismissible: false,\n }, app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n }))\n : Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.forum.modal.ban_ip_no_users'))\n : ''}\n\n {otherUsersBanned &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n reason: this.reason(),\n userId: this.user.id(),\n };\n\n if (this.banOption() === 'only') {\n attrs.address = this.post.ipAddress();\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/ban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => app.store.pushPayload(res).forEach(this.done.bind(this)))\n .then(this.hide.bind(this))\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') data.ip = this.address || this.post.ipAddress();\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users/${this.user.id()}`,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n this.otherUsers[this.banOption()] = res.data.map((e) => app.store.pushObject(e)).filter((e) => e.bannedIPs().length === 0);\n this.loading = false;\n })\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n const obj = {\n type: 'banned_ips',\n id: bannedIP.id(),\n };\n\n if (this.post) {\n this.post.data.relationships.banned_ip = {\n data: obj,\n };\n }\n\n if (!this.user.data.relationships.banned_ips)\n this.user.data.relationships.banned_ips = {\n data: [],\n };\n\n this.user.data.relationships.banned_ips.data.push(obj);\n this.user.data.attributes.isBanned = true;\n\n app.store.pushObject(this.user.data);\n }\n}\n","module.exports = flarum.core.compat['utils/Stream'];","import Button from 'flarum/components/Button';\nimport Alert from 'flarum/components/Alert';\nimport punctuateSeries from 'flarum/helpers/punctuateSeries';\nimport username from 'flarum/helpers/username';\n\nimport BanIPModal from './BanIPModal';\n\nexport default class UnbanIPModal extends BanIPModal {\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.unban_title');\n }\n\n content() {\n const otherUsers = this.otherUsers[this.banOption()];\n const usernames = otherUsers && otherUsers.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n if (this.bannedIPs) {\n return (\n
\n {Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.lib.modal.unbanned_ips', { ips: punctuateSeries(this.bannedIPs) }))}\n
\n );\n }\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.unban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n {otherUsers\n ? otherUsers.length\n ? Alert.component({\n dismissible: false,\n }, app.translator.transChoice('fof-ban-ips.lib.modal.unban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n }))\n : Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.lib.modal.unban_ip_no_users'))\n : ''}\n\n {otherUsers &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {};\n\n if (this.banOption() === 'only') {\n attrs.address = this.address || this.post.ipAddress();\n\n const bannedIP = this.post ? this.post.bannedIP() : app.store.getBy('banned_ips', 'address', this.address);\n\n bannedIP.delete().then(this.done.bind(this, bannedIP)).catch(this.onerror.bind(this)).then(this.hide.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/unban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then(this.done.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.hide.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') {\n data.ip = this.address || this.post.ipAddress();\n data.skipValidation = true;\n }\n\n let url = `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`;\n\n if (this.user) url += `/${this.user.id()}`;\n\n app.request({\n params: data,\n url: url,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n const data = app.store.pushPayload(res);\n\n this.otherUsers[this.banOption()] = data.filter((e) => e.bannedIPs().length === 1);\n this.loading = false;\n\n m.redraw();\n })\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n this.loading = false;\n\n if (this.post) delete this.post.data.relationships.banned_ip;\n\n if (this.user && !this.user.data.relationships && !bannedIP) {\n this.user.data.relationships.banned_ips.data = [];\n this.user.data.attributes.isBanned = false;\n } else if (this.user && bannedIP instanceof app.store.models.banned_ips) {\n this.user.data.relationships.banned_ips = {\n data: this.user.data.relationships.banned_ips.data.filter((e) => e.id !== bannedIP.id()),\n };\n this.user.data.attributes.isBanned = this.user.data.relationships.banned_ips.data.length !== 0;\n }\n\n if (bannedIP && Array.isArray(bannedIP.data)) {\n this.bannedIPs = bannedIP.data.map((b) => b.attributes.address);\n this.loading = false;\n\n m.redraw();\n }\n }\n\n hide() {\n super.hide();\n\n if (!this.attrs.redraw) {\n location.reload();\n }\n }\n}\n","module.exports = flarum.core.compat['components/Modal'];","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class BannedIP extends mixin(Model, {\n creator: Model.hasOne('creator'),\n user: Model.hasOne('user'),\n address: Model.attribute('address'),\n reason: Model.attribute('reason'),\n createdAt: Model.attribute('createdAt', Model.transformDate),\n deletedAt: Model.attribute('deletedAt', Model.transformDate),\n}) {\n apiEndpoint() {\n return `/fof/ban-ips${this.exists ? `/${this.id()}` : ''}`;\n }\n}\n","module.exports = flarum.core.compat['helpers/username'];","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['utils/mixin'];","import BanIPModal from './components/BanIPModal';\nimport UnbanIPModal from './components/UnbanIPModal';\nimport BannedIP from './models/BannedIP';\n\nexport default {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/UnbanIPModal': UnbanIPModal,\n 'fof/ban-ips/models/BannedIP': BannedIP,\n};\n","module.exports = flarum.core;","module.exports = flarum.core.compat['components/LoadingIndicator'];","module.exports = flarum.core.compat['components/Placeholder'];","module.exports = flarum.core.compat['components/ExtensionPage'];","module.exports = flarum.core.compat['Component'];","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport Alert from 'flarum/components/Alert';\nimport punctuateSeries from 'flarum/helpers/punctuateSeries';\nimport username from 'flarum/helpers/username';\nimport Stream from 'flarum/utils/Stream';\n\nexport default class BanIPModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.address = Stream('');\n this.reason = Stream('');\n\n this.usersBanned = {};\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.title');\n }\n\n content() {\n const usersBanned = this.usersBanned[this.address()];\n const usernames = usersBanned && usersBanned.map(username);\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n \n \n
\n\n
\n \n \n
\n\n {usersBanned\n ? usersBanned.length\n ? Alert.component({\n dismissible: false,\n }, app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n }))\n : Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.admin.modal.ban_ip_no_users'))\n : ''}\n\n {usersBanned &&
}\n\n
\n \n {usernames\n ? app.translator.trans('fof-ban-ips.lib.modal.ban_button')\n : app.translator.trans('fof-ban-ips.lib.modal.check_button')}\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n if (!this.address()) return;\n\n this.loading = true;\n\n if (typeof this.usersBanned[this.address()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n address: this.address(),\n reason: this.reason(),\n };\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this), this.onerror.bind(this), this.loaded.bind(this));\n }\n\n getOtherUsers() {\n const data = {\n ip: this.address(),\n };\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`,\n method: 'GET',\n })\n .then((res) => {\n this.usersBanned[this.address()] = res.data.map((e) => app.store.pushObject(e));\n\n m.redraw();\n })\n .then(this.loaded.bind(this))\n .catch((e) => {\n this.onerror(e);\n this.loading = false;\n });\n }\n}\n","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport Stream from 'flarum/utils/Stream';\n\nexport default class ChangeReasonModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.item = this.attrs.item;\n\n this.reason = Stream(this.item.reason());\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.admin.modal.update_title');\n }\n\n content() {\n return (\n
\n
\n \n \n
\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n if (!this.reason()) return;\n\n this.loading = true;\n\n this.item\n .save({\n reason: this.reason(),\n })\n .then(this.hide.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.loaded.bind(this));\n }\n}\n","import Component from 'flarum/Component';\nimport Button from 'flarum/components/Button';\nimport username from 'flarum/helpers/username';\n\nimport UnbanIPModal from '../../common/components/UnbanIPModal';\nimport ChangeReasonModal from './ChangeReasonModal';\n\nexport default class SettingsPageItem extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.item = this.attrs.bannedIP;\n }\n\n view() {\n return (\n \n {this.item.id()}\n {username(this.item.creator())}\n {this.item.user() && username(this.item.user())}\n {this.item.address()}\n {this.item.reason()}\n {this.item.createdAt().toLocaleDateString()}\n \n
\n {Button.component({\n className: 'Button Button--warning',\n icon: 'fas fa-pencil-alt',\n disabled: this.item.creator() !== app.session.user,\n onclick: () => app.modal.show(ChangeReasonModal, { item: this.item }),\n })}\n {Button.component({\n className: 'Button Button--danger',\n icon: 'fas fa-times',\n onclick: () => app.modal.show(UnbanIPModal, { address: this.item.address(), redraw: true }),\n })}\n
\n \n \n );\n }\n}\n","import Button from 'flarum/components/Button';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport Placeholder from 'flarum/components/Placeholder';\nimport ExtensionPage from 'flarum/components/ExtensionPage';\n\nimport BanIPModal from './BanIPModal';\nimport SettingsPageItem from './SettingsPageItem';\n\nexport default class SettingsPage extends ExtensionPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = true;\n\n this.page = 0;\n this.pageSize = 20;\n }\n\n oncreate(vnode) {\n super.oncreate(vnode)\n\n this.refresh();\n }\n\n content() {\n let next, prev;\n\n if (this.nextResults === true) {\n next = Button.component({\n className: 'Button Button--PageList-next',\n icon: 'fas fa-angle-right',\n onclick: this.loadNext.bind(this),\n });\n }\n\n if (this.prevResults === true) {\n prev = Button.component({\n className: 'Button Button--PageList-prev',\n icon: 'fas fa-angle-left',\n onclick: this.loadPrev.bind(this),\n });\n }\n\n return (\n
\n
\n
\n {Button.component({\n className: 'Button Button--primary',\n icon: 'fas fa-plus',\n onclick: () => app.modal.show(BanIPModal),\n }, app.translator.trans('fof-ban-ips.admin.page.create_button'))}\n
\n
\n
\n
\n
\n {this.loading ? (\n LoadingIndicator.component()\n ) : app.store.all('banned_ips').length ? (\n \n \n \n \n \n \n \n \n \n \n \n \n {app.store\n .all('banned_ips')\n .slice(this.page, this.page + this.pageSize)\n .map((bannedIP) => SettingsPageItem.component({ bannedIP }))}\n \n
#{app.translator.trans('fof-ban-ips.admin.page.creator_label')}{app.translator.trans('fof-ban-ips.admin.page.user_label')}{app.translator.trans('fof-ban-ips.admin.page.address_label')}{app.translator.trans('fof-ban-ips.admin.page.reason_label')}{app.translator.trans('fof-ban-ips.admin.page.date_label')}\n
\n ) : (\n
{Placeholder.component({ text: app.translator.trans('fof-ban-ips.admin.empty_text') })}
\n )}\n
\n
\n
\n {next}\n {prev}\n
\n
\n );\n }\n\n refresh() {\n return this.loadResults().then(this.parseResults.bind(this));\n }\n\n /**\n * Load a new page of Pages results.\n *\n * @param {Integer} page number.\n * @return {Promise}\n */\n loadResults() {\n const offset = this.page * this.pageSize;\n\n return app.store.find('fof/ban-ips', { page: { offset, limit: this.pageSize } });\n }\n\n /**\n * Load the next page of results.\n *\n * @public\n */\n loadNext() {\n if (this.nextResults === true) {\n this.page++;\n this.refresh();\n }\n }\n\n /**\n * Load the previous page of results.\n *\n * @public\n */\n loadPrev() {\n if (this.prevResults === true) {\n this.page--;\n this.refresh();\n }\n }\n\n /**\n * Parse results and append them to the page list.\n *\n * @param {Page[]} results\n * @return {Page[]}\n */\n parseResults(results) {\n this.loading = false;\n\n this.nextResults = !!results.payload.links.next;\n this.prevResults = !!results.payload.links.prev;\n\n m.redraw();\n }\n}\n","import compat from '../common/compat';\n\nimport BanIPModal from './components/BanIPModal';\nimport ChangeReasonModal from './components/ChangeReasonModal';\nimport SettingsPage from './components/SettingsPage';\nimport SettingsPageItem from './components/SettingsPageItem';\n\nexport default Object.assign(compat, {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/ChangeReasonModal': ChangeReasonModal,\n 'fof/ban-ips/components/SettingsPage': SettingsPage,\n 'fof/ban-ips/components/SettingsPageItem': SettingsPageItem,\n});\n","import app from 'flarum/app';\nimport Model from 'flarum/Model';\n\nimport BannedIP from '../common/models/BannedIP';\nimport SettingsPage from './components/SettingsPage';\n\napp.initializers.add('fof/ban-ips', () => {\n app.store.models.banned_ips = BannedIP;\n\n app.store.models.users.prototype.bannedIPs = Model.hasMany('banned_ips');\n\n app.extensionData.for('fof-ban-ips')\n .registerPermission({\n icon: 'fas fa-gavel',\n label: app.translator.trans('fof-ban-ips.admin.permissions.view_banned_ip_list_label'),\n permission: 'fof.ban-ips.viewBannedIPList',\n }, 'moderate')\n .registerPermission({\n icon: 'fas fa-gavel',\n label: app.translator.trans('fof-ban-ips.admin.permissions.ban_ip_label'),\n permission: 'fof.ban-ips.banIP',\n }, 'moderate')\n .registerPage(SettingsPage);\n});\n\n// Expose compat API\nimport extCompat from './compat';\nimport { compat } from '@flarum/core/admin';\n\nObject.assign(compat, extCompat);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@fof/ban-ips/webpack/bootstrap","webpack://@fof/ban-ips/external \"flarum.core.compat['common/Model']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Button']\"","webpack://@fof/ban-ips/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/ban-ips/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/helpers/punctuateSeries']\"","webpack://@fof/ban-ips/./src/common/components/BanIPModal.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/utils/Stream']\"","webpack://@fof/ban-ips/./src/common/components/UnbanIPModal.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/ban-ips/./src/common/models/BannedIP.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/helpers/username']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['admin/app']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/utils/mixin']\"","webpack://@fof/ban-ips/./src/common/compat.js","webpack://@fof/ban-ips/external \"flarum.core\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/LoadingIndicator']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Placeholder']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['admin/components/ExtensionPage']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/Component']\"","webpack://@fof/ban-ips/./src/admin/components/BanIPModal.js","webpack://@fof/ban-ips/./src/admin/components/ChangeReasonModal.js","webpack://@fof/ban-ips/./src/admin/components/SettingsPageItem.js","webpack://@fof/ban-ips/./src/admin/components/SettingsPage.js","webpack://@fof/ban-ips/./src/admin/compat.js","webpack://@fof/ban-ips/./src/admin/index.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","constructor","BanIPModal","oninit","vnode","this","address","attrs","post","user","bannedIP","app","store","getBy","banOptions","ipAddress","push","banOption","Stream","reason","otherUsers","loading","className","title","translator","trans","content","otherUsersBanned","usernames","map","u","displayName","type","id","checked","onclick","htmlFor","ip","bidi","length","Alert","component","dismissible","transChoice","users","punctuateSeries","onsubmit","e","preventDefault","getOtherUsers","userId","createRecord","save","then","hide","onerror","loaded","request","body","data","attributes","url","forum","attribute","apiEndpoint","method","errorHandler","res","pushPayload","forEach","done","params","pushObject","filter","bannedIPs","obj","relationships","banned_ip","banned_ips","isBanned","Modal","UnbanIPModal","ips","skipValidation","redraw","models","Array","isArray","b","location","reload","BannedIP","exists","mixin","Model","creator","hasOne","createdAt","transformDate","deletedAt","usersBanned","username","required","pattern","disabled","ChangeReasonModal","item","SettingsPageItem","view","toLocaleDateString","Button","icon","session","modal","show","Component","SettingsPage","page","pageSize","oncreate","refresh","next","prev","nextResults","loadNext","prevResults","loadPrev","LoadingIndicator","all","style","width","textAlign","slice","Placeholder","text","loadResults","parseResults","offset","find","limit","results","payload","links","ExtensionPage","assign","initializers","add","hasMany","extensionData","registerPermission","label","permission","registerPage","extCompat"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAG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KsH,cAAgBiB,EAAQC,QAAQC,MAAMrB,KAC3CpH,KAAKwH,cAAgBe,EAAQC,QAAQC,MAAMpB,KAE3C9J,EAAEwH,U,GA3IgC2D,K,QCD3B7K,SAAO8K,OAAOtJ,IAAQ,CACjC,oCAAqCQ,EACrC,2CAA4CuG,EAC5C,sCAAuCW,EACvC,0CAA2CT,I,QCL/ChG,IAAIsI,aAAaC,IAAI,eAAe,WAChCvI,IAAIC,MAAMyE,OAAOP,WAAaa,IAE9BhF,IAAIC,MAAMyE,OAAOzC,MAAMxD,UAAUsF,UAAYoB,IAAMqD,QAAQ,cAE3DxI,IAAIyI,cAAJ,IACS,eACJC,mBACG,CACItC,KAAM,eACNuC,MAAO3I,IAAIa,WAAWC,MAAM,2DAC5B8H,WAAY,gCAEhB,YAEHF,mBACG,CACItC,KAAM,eACNuC,MAAO3I,IAAIa,WAAWC,MAAM,8CAC5B8H,WAAY,qBAEhB,YAEHC,aAAapC,MAOtBlJ,OAAO8K,OAAOtJ,SAAQ+J","file":"admin.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 25);\n","module.exports = flarum.core.compat['common/Model'];","module.exports = flarum.core.compat['common/components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","module.exports = flarum.core.compat['common/components/Alert'];","module.exports = flarum.core.compat['common/helpers/punctuateSeries'];","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport Stream from 'flarum/common/utils/Stream';\nimport punctuateSeries from 'flarum/common/helpers/punctuateSeries';\n\nexport default class BanIPModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.address = this.attrs.address;\n this.post = this.attrs.post;\n this.user = this.attrs.user || (this.post && this.post.user());\n\n if (!this.user && this.address) {\n const bannedIP = app.store.getBy('banned_ips', 'address', this.address);\n\n if (bannedIP) this.user = bannedIP.user();\n }\n\n this.banOptions = [];\n\n if ((this.post && this.post.ipAddress()) || this.address) this.banOptions.push('only');\n if (this.user) this.banOptions.push('all');\n\n this.banOption = Stream(this.banOptions[0]);\n this.reason = Stream('');\n\n this.otherUsers = {};\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.title');\n }\n\n content() {\n const otherUsersBanned = this.otherUsers[this.banOption()];\n const usernames =\n otherUsersBanned && otherUsersBanned.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n
\n \n \n
\n\n {otherUsersBanned\n ? otherUsersBanned.length\n ? Alert.component(\n {\n dismissible: false,\n },\n app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n })\n )\n : Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.forum.modal.ban_ip_no_users')\n )\n : ''}\n\n {otherUsersBanned &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n reason: this.reason(),\n userId: this.user.id(),\n };\n\n if (this.banOption() === 'only') {\n attrs.address = this.post.ipAddress();\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/ban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => app.store.pushPayload(res).forEach(this.done.bind(this)))\n .then(this.hide.bind(this))\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') data.ip = this.address || this.post.ipAddress();\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users/${this.user.id()}`,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n this.otherUsers[this.banOption()] = res.data.map((e) => app.store.pushObject(e)).filter((e) => e.bannedIPs().length === 0);\n this.loading = false;\n })\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n const obj = {\n type: 'banned_ips',\n id: bannedIP.id(),\n };\n\n if (this.post) {\n this.post.data.relationships.banned_ip = {\n data: obj,\n };\n }\n\n if (!this.user.data.relationships.banned_ips)\n this.user.data.relationships.banned_ips = {\n data: [],\n };\n\n this.user.data.relationships.banned_ips.data.push(obj);\n this.user.data.attributes.isBanned = true;\n\n app.store.pushObject(this.user.data);\n }\n}\n","module.exports = flarum.core.compat['common/utils/Stream'];","import Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport punctuateSeries from 'flarum/common/helpers/punctuateSeries';\nimport username from 'flarum/common/helpers/username';\n\nimport BanIPModal from './BanIPModal';\n\nexport default class UnbanIPModal extends BanIPModal {\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.unban_title');\n }\n\n content() {\n const otherUsers = this.otherUsers[this.banOption()];\n const usernames = otherUsers && otherUsers.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n if (this.bannedIPs) {\n return (\n
\n {Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.lib.modal.unbanned_ips', { ips: punctuateSeries(this.bannedIPs) })\n )}\n
\n );\n }\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.unban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n {otherUsers\n ? otherUsers.length\n ? Alert.component(\n {\n dismissible: false,\n },\n app.translator.transChoice('fof-ban-ips.lib.modal.unban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n })\n )\n : Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.lib.modal.unban_ip_no_users')\n )\n : ''}\n\n {otherUsers &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {};\n\n if (this.banOption() === 'only') {\n attrs.address = this.address || this.post.ipAddress();\n\n const bannedIP = this.post ? this.post.bannedIP() : app.store.getBy('banned_ips', 'address', this.address);\n\n bannedIP.delete().then(this.done.bind(this, bannedIP)).catch(this.onerror.bind(this)).then(this.hide.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/unban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then(this.done.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.hide.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') {\n data.ip = this.address || this.post.ipAddress();\n data.skipValidation = true;\n }\n\n let url = `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`;\n\n if (this.user) url += `/${this.user.id()}`;\n\n app.request({\n params: data,\n url: url,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n const data = app.store.pushPayload(res);\n\n this.otherUsers[this.banOption()] = data.filter((e) => e.bannedIPs().length === 1);\n this.loading = false;\n\n m.redraw();\n })\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n this.loading = false;\n\n if (this.post) delete this.post.data.relationships.banned_ip;\n\n if (this.user && !this.user.data.relationships && !bannedIP) {\n this.user.data.relationships.banned_ips.data = [];\n this.user.data.attributes.isBanned = false;\n } else if (this.user && bannedIP instanceof app.store.models.banned_ips) {\n this.user.data.relationships.banned_ips = {\n data: this.user.data.relationships.banned_ips.data.filter((e) => e.id !== bannedIP.id()),\n };\n this.user.data.attributes.isBanned = this.user.data.relationships.banned_ips.data.length !== 0;\n }\n\n if (bannedIP && Array.isArray(bannedIP.data)) {\n this.bannedIPs = bannedIP.data.map((b) => b.attributes.address);\n this.loading = false;\n\n m.redraw();\n }\n }\n\n hide() {\n super.hide();\n\n if (!this.attrs.redraw) {\n location.reload();\n }\n }\n}\n","module.exports = flarum.core.compat['common/components/Modal'];","import Model from 'flarum/common/Model';\nimport mixin from 'flarum/common/utils/mixin';\n\nexport default class BannedIP extends mixin(Model, {\n creator: Model.hasOne('creator'),\n user: Model.hasOne('user'),\n address: Model.attribute('address'),\n reason: Model.attribute('reason'),\n createdAt: Model.attribute('createdAt', Model.transformDate),\n deletedAt: Model.attribute('deletedAt', Model.transformDate),\n}) {\n apiEndpoint() {\n return `/fof/ban-ips${this.exists ? `/${this.id()}` : ''}`;\n }\n}\n","module.exports = flarum.core.compat['common/helpers/username'];","module.exports = flarum.core.compat['admin/app'];","module.exports = flarum.core.compat['common/utils/mixin'];","import BanIPModal from './components/BanIPModal';\nimport UnbanIPModal from './components/UnbanIPModal';\nimport BannedIP from './models/BannedIP';\n\nexport default {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/UnbanIPModal': UnbanIPModal,\n 'fof/ban-ips/models/BannedIP': BannedIP,\n};\n","module.exports = flarum.core;","module.exports = flarum.core.compat['common/components/LoadingIndicator'];","module.exports = flarum.core.compat['common/components/Placeholder'];","module.exports = flarum.core.compat['admin/components/ExtensionPage'];","module.exports = flarum.core.compat['common/Component'];","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport punctuateSeries from 'flarum/common/helpers/punctuateSeries';\nimport username from 'flarum/common/helpers/username';\nimport Stream from 'flarum/common/utils/Stream';\n\nexport default class BanIPModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.address = Stream('');\n this.reason = Stream('');\n\n this.usersBanned = {};\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.title');\n }\n\n content() {\n const usersBanned = this.usersBanned[this.address()];\n const usernames = usersBanned && usersBanned.map(username);\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n \n \n
\n\n
\n \n \n
\n\n {usersBanned\n ? usersBanned.length\n ? Alert.component(\n {\n dismissible: false,\n },\n app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n })\n )\n : Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.admin.modal.ban_ip_no_users')\n )\n : ''}\n\n {usersBanned &&
}\n\n
\n \n {usernames\n ? app.translator.trans('fof-ban-ips.lib.modal.ban_button')\n : app.translator.trans('fof-ban-ips.lib.modal.check_button')}\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n if (!this.address()) return;\n\n this.loading = true;\n\n if (typeof this.usersBanned[this.address()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n address: this.address(),\n reason: this.reason(),\n };\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this), this.onerror.bind(this), this.loaded.bind(this));\n }\n\n getOtherUsers() {\n const data = {\n ip: this.address(),\n };\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`,\n method: 'GET',\n })\n .then((res) => {\n this.usersBanned[this.address()] = res.data.map((e) => app.store.pushObject(e));\n\n m.redraw();\n })\n .then(this.loaded.bind(this))\n .catch((e) => {\n this.onerror(e);\n this.loading = false;\n });\n }\n}\n","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport Stream from 'flarum/common/utils/Stream';\n\nexport default class ChangeReasonModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.item = this.attrs.item;\n\n this.reason = Stream(this.item.reason());\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.admin.modal.update_title');\n }\n\n content() {\n return (\n
\n
\n \n \n
\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n if (!this.reason()) return;\n\n this.loading = true;\n\n this.item\n .save({\n reason: this.reason(),\n })\n .then(this.hide.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.loaded.bind(this));\n }\n}\n","import Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport username from 'flarum/common/helpers/username';\n\nimport UnbanIPModal from '../../common/components/UnbanIPModal';\nimport ChangeReasonModal from './ChangeReasonModal';\n\nexport default class SettingsPageItem extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.item = this.attrs.bannedIP;\n }\n\n view() {\n return (\n \n {this.item.id()}\n {username(this.item.creator())}\n {this.item.user() && username(this.item.user())}\n {this.item.address()}\n {this.item.reason()}\n {this.item.createdAt().toLocaleDateString()}\n \n
\n {Button.component({\n className: 'Button Button--warning',\n icon: 'fas fa-pencil-alt',\n disabled: this.item.creator() !== app.session.user,\n onclick: () => app.modal.show(ChangeReasonModal, { item: this.item }),\n })}\n {Button.component({\n className: 'Button Button--danger',\n icon: 'fas fa-times',\n onclick: () => app.modal.show(UnbanIPModal, { address: this.item.address(), redraw: true }),\n })}\n
\n \n \n );\n }\n}\n","import Button from 'flarum/common/components/Button';\nimport LoadingIndicator from 'flarum/common/components/LoadingIndicator';\nimport Placeholder from 'flarum/common/components/Placeholder';\nimport ExtensionPage from 'flarum/admin/components/ExtensionPage';\n\nimport BanIPModal from './BanIPModal';\nimport SettingsPageItem from './SettingsPageItem';\n\nexport default class SettingsPage extends ExtensionPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = true;\n\n this.page = 0;\n this.pageSize = 20;\n }\n\n oncreate(vnode) {\n super.oncreate(vnode);\n\n this.refresh();\n }\n\n content() {\n let next, prev;\n\n if (this.nextResults === true) {\n next = Button.component({\n className: 'Button Button--PageList-next',\n icon: 'fas fa-angle-right',\n onclick: this.loadNext.bind(this),\n });\n }\n\n if (this.prevResults === true) {\n prev = Button.component({\n className: 'Button Button--PageList-prev',\n icon: 'fas fa-angle-left',\n onclick: this.loadPrev.bind(this),\n });\n }\n\n return (\n
\n
\n
\n {Button.component(\n {\n className: 'Button Button--primary',\n icon: 'fas fa-plus',\n onclick: () => app.modal.show(BanIPModal),\n },\n app.translator.trans('fof-ban-ips.admin.page.create_button')\n )}\n
\n
\n
\n
\n
\n {this.loading ? (\n LoadingIndicator.component()\n ) : app.store.all('banned_ips').length ? (\n \n \n \n \n \n \n \n \n \n \n \n \n {app.store\n .all('banned_ips')\n .slice(this.page, this.page + this.pageSize)\n .map((bannedIP) => SettingsPageItem.component({ bannedIP }))}\n \n
#{app.translator.trans('fof-ban-ips.admin.page.creator_label')}{app.translator.trans('fof-ban-ips.admin.page.user_label')}{app.translator.trans('fof-ban-ips.admin.page.address_label')}{app.translator.trans('fof-ban-ips.admin.page.reason_label')}{app.translator.trans('fof-ban-ips.admin.page.date_label')}\n
\n ) : (\n
{Placeholder.component({ text: app.translator.trans('fof-ban-ips.admin.empty_text') })}
\n )}\n
\n
\n
\n {next}\n {prev}\n
\n
\n );\n }\n\n refresh() {\n return this.loadResults().then(this.parseResults.bind(this));\n }\n\n /**\n * Load a new page of Pages results.\n *\n * @param {Integer} page number.\n * @return {Promise}\n */\n loadResults() {\n const offset = this.page * this.pageSize;\n\n return app.store.find('fof/ban-ips', { page: { offset, limit: this.pageSize } });\n }\n\n /**\n * Load the next page of results.\n *\n * @public\n */\n loadNext() {\n if (this.nextResults === true) {\n this.page++;\n this.refresh();\n }\n }\n\n /**\n * Load the previous page of results.\n *\n * @public\n */\n loadPrev() {\n if (this.prevResults === true) {\n this.page--;\n this.refresh();\n }\n }\n\n /**\n * Parse results and append them to the page list.\n *\n * @param {Page[]} results\n * @return {Page[]}\n */\n parseResults(results) {\n this.loading = false;\n\n this.nextResults = !!results.payload.links.next;\n this.prevResults = !!results.payload.links.prev;\n\n m.redraw();\n }\n}\n","import compat from '../common/compat';\n\nimport BanIPModal from './components/BanIPModal';\nimport ChangeReasonModal from './components/ChangeReasonModal';\nimport SettingsPage from './components/SettingsPage';\nimport SettingsPageItem from './components/SettingsPageItem';\n\nexport default Object.assign(compat, {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/ChangeReasonModal': ChangeReasonModal,\n 'fof/ban-ips/components/SettingsPage': SettingsPage,\n 'fof/ban-ips/components/SettingsPageItem': SettingsPageItem,\n});\n","import app from 'flarum/admin/app';\nimport Model from 'flarum/common/Model';\n\nimport BannedIP from '../common/models/BannedIP';\nimport SettingsPage from './components/SettingsPage';\n\napp.initializers.add('fof/ban-ips', () => {\n app.store.models.banned_ips = BannedIP;\n\n app.store.models.users.prototype.bannedIPs = Model.hasMany('banned_ips');\n\n app.extensionData\n .for('fof-ban-ips')\n .registerPermission(\n {\n icon: 'fas fa-gavel',\n label: app.translator.trans('fof-ban-ips.admin.permissions.view_banned_ip_list_label'),\n permission: 'fof.ban-ips.viewBannedIPList',\n },\n 'moderate'\n )\n .registerPermission(\n {\n icon: 'fas fa-gavel',\n label: app.translator.trans('fof-ban-ips.admin.permissions.ban_ip_label'),\n permission: 'fof.ban-ips.banIP',\n },\n 'moderate'\n )\n .registerPage(SettingsPage);\n});\n\n// Expose compat API\nimport extCompat from './compat';\nimport { compat } from '@flarum/core/admin';\n\nObject.assign(compat, extCompat);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/dist/forum.js b/js/dist/forum.js index cb5136e..b27c3b5 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var n={};function a(s){if(n[s])return n[s].exports;var e=n[s]={i:s,l:!1,exports:{}};return t[s].call(e.exports,e,e.exports,a),e.l=!0,e.exports}return a.m=t,a.c=n,a.d=function(t,n,s){a.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:s})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,n){if(1&n&&(t=a(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(a.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var e in t)a.d(s,e,function(n){return t[n]}.bind(null,e));return s},a.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(n,"a",n),n},a.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},a.p="",a(a.s=26)}([function(t,n){t.exports=flarum.core.compat.Model},function(t,n){t.exports=flarum.core.compat["components/Button"]},function(t,n,a){"use strict";function s(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}a.d(n,"a",(function(){return s}))},function(t,n){t.exports=flarum.core.compat["components/Alert"]},function(t,n){t.exports=flarum.core.compat["helpers/punctuateSeries"]},function(t,n,a){"use strict";a.d(n,"a",(function(){return b}));var s=a(2),e=a(8),r=a.n(e),i=a(1),o=a.n(i),p=a(3),d=a.n(p),u=a(6),l=a.n(u),c=a(4),h=a.n(c),b=function(t){function n(){return t.apply(this,arguments)||this}Object(s.a)(n,t);var a=n.prototype;return a.oninit=function(n){if(t.prototype.oninit.call(this,n),this.address=this.attrs.address,this.post=this.attrs.post,this.user=this.attrs.user||this.post&&this.post.user(),!this.user&&this.address){var a=app.store.getBy("banned_ips","address",this.address);a&&(this.user=a.user())}this.banOptions=[],(this.post&&this.post.ipAddress()||this.address)&&this.banOptions.push("only"),this.user&&this.banOptions.push("all"),this.banOption=l()(this.banOptions[0]),this.reason=l()(""),this.otherUsers={},this.loading=!1},a.className=function(){return"Modal--medium"},a.title=function(){return app.translator.trans("fof-ban-ips.lib.modal.title")},a.content=function(){var t=this,n=this.otherUsers[this.banOption()],a=n&&n.map((function(t){return t&&t.displayName()||app.translator.trans("core.lib.username.deleted_text")}));return m("div",{className:"Modal-body"},m("p",null,app.translator.trans("fof-ban-ips.lib.modal.ban_ip_confirmation")),m("div",{className:"Form-group"},this.banOptions.map((function(n){return m("div",null,m("input",{type:"radio",name:"ban-option",id:"ban-option-"+n,checked:t.banOption()===n,onclick:t.banOption.bind(t,n)})," ",m("label",{htmlFor:"ban-option-"+n},app.translator.trans("fof-ban-ips.forum.modal.ban_options_"+n+"_ip",{user:t.user,ip:t.address||t.post&&t.post.ipAddress()})))}))),m("div",{className:"Form-group"},m("label",{className:"label"},app.translator.trans("fof-ban-ips.lib.modal.reason_label")),m("input",{type:"text",className:"FormControl",bidi:this.reason})),n?n.length?d.a.component({dismissible:!1},app.translator.transChoice("fof-ban-ips.lib.modal.ban_ip_users",a.length,{users:h()(a)})):d.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.forum.modal.ban_ip_no_users")):"",n&&m("br",null),m("div",{className:"Form-group"},m(o.a,{className:"Button Button--primary",type:"submit",loading:this.loading},a?app.translator.trans("fof-ban-ips.lib.modal.ban_button"):app.translator.trans("fof-ban-ips.lib.modal.check_button"))))},a.onsubmit=function(t){var n=this;if(t.preventDefault(),this.loading=!0,void 0===this.otherUsers[this.banOption()])return this.getOtherUsers();var a={reason:this.reason(),userId:this.user.id()};"only"===this.banOption()?(a.address=this.post.ipAddress(),app.store.createRecord("banned_ips").save(a).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this))):"all"===this.banOption()&&app.request({body:{data:{attributes:a}},url:""+app.forum.attribute("apiUrl")+this.user.apiEndpoint()+"/ban",method:"POST",errorHandler:this.onerror.bind(this)}).then((function(t){return app.store.pushPayload(t).forEach(n.done.bind(n))})).then(this.hide.bind(this)).catch((function(){})).then(this.loaded.bind(this))},a.getOtherUsers=function(){var t=this,n={};"only"===this.banOption()&&(n.ip=this.address||this.post.ipAddress()),app.request({params:n,url:app.forum.attribute("apiUrl")+"/fof/ban-ips/check-users/"+this.user.id(),method:"GET",errorHandler:this.onerror.bind(this)}).then((function(n){t.otherUsers[t.banOption()]=n.data.map((function(t){return app.store.pushObject(t)})).filter((function(t){return 0===t.bannedIPs().length})),t.loading=!1})).catch((function(){})).then(this.loaded.bind(this))},a.done=function(t){var n={type:"banned_ips",id:t.id()};this.post&&(this.post.data.relationships.banned_ip={data:n}),this.user.data.relationships.banned_ips||(this.user.data.relationships.banned_ips={data:[]}),this.user.data.relationships.banned_ips.data.push(n),this.user.data.attributes.isBanned=!0,app.store.pushObject(this.user.data)},n}(r.a)},function(t,n){t.exports=flarum.core.compat["utils/Stream"]},function(t,n,a){"use strict";a.d(n,"a",(function(){return u}));var s=a(2),e=a(1),r=a.n(e),i=a(3),o=a.n(i),p=a(4),d=a.n(p),u=(a(10),function(t){function n(){return t.apply(this,arguments)||this}Object(s.a)(n,t);var a=n.prototype;return a.title=function(){return app.translator.trans("fof-ban-ips.lib.modal.unban_title")},a.content=function(){var t=this,n=this.otherUsers[this.banOption()],a=n&&n.map((function(t){return t&&t.displayName()||app.translator.trans("core.lib.username.deleted_text")}));return this.bannedIPs?m("div",{className:"Modal-body"},o.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.lib.modal.unbanned_ips",{ips:d()(this.bannedIPs)}))):m("div",{className:"Modal-body"},m("p",null,app.translator.trans("fof-ban-ips.lib.modal.unban_ip_confirmation")),m("div",{className:"Form-group"},this.banOptions.map((function(n){return m("div",null,m("input",{type:"radio",name:"ban-option",id:"ban-option-"+n,checked:t.banOption()===n,onclick:t.banOption.bind(t,n)})," ",m("label",{htmlFor:"ban-option-"+n},app.translator.trans("fof-ban-ips.lib.modal.unban_options_"+n+"_ip",{user:t.user,ip:t.address||t.post&&t.post.ipAddress()})))}))),n?n.length?o.a.component({dismissible:!1},app.translator.transChoice("fof-ban-ips.lib.modal.unban_ip_users",a.length,{users:d()(a)})):o.a.component({dismissible:!1,type:"success"},app.translator.trans("fof-ban-ips.lib.modal.unban_ip_no_users")):"",n&&m("br",null),m("div",{className:"Form-group"},m(r.a,{className:"Button Button--primary",type:"submit",loading:this.loading},a?app.translator.trans("fof-ban-ips.lib.modal.unban_button"):app.translator.trans("fof-ban-ips.lib.modal.check_button"))))},a.onsubmit=function(t){if(t.preventDefault(),this.loading=!0,void 0===this.otherUsers[this.banOption()])return this.getOtherUsers();var n={};if("only"===this.banOption()){n.address=this.address||this.post.ipAddress();var a=this.post?this.post.bannedIP():app.store.getBy("banned_ips","address",this.address);a.delete().then(this.done.bind(this,a)).catch(this.onerror.bind(this)).then(this.hide.bind(this))}else"all"===this.banOption()&&app.request({body:{data:{attributes:n}},url:""+app.forum.attribute("apiUrl")+this.user.apiEndpoint()+"/unban",method:"POST",errorHandler:this.onerror.bind(this)}).then(this.done.bind(this)).catch(this.onerror.bind(this)).then(this.hide.bind(this))},a.getOtherUsers=function(){var t=this,n={};"only"===this.banOption()&&(n.ip=this.address||this.post.ipAddress(),n.skipValidation=!0);var a=app.forum.attribute("apiUrl")+"/fof/ban-ips/check-users";this.user&&(a+="/"+this.user.id()),app.request({params:n,url:a,method:"GET",errorHandler:this.onerror.bind(this)}).then((function(n){var a=app.store.pushPayload(n);t.otherUsers[t.banOption()]=a.filter((function(t){return 1===t.bannedIPs().length})),t.loading=!1,m.redraw()})).catch((function(){})).then(this.loaded.bind(this))},a.done=function(t){this.loading=!1,this.post&&delete this.post.data.relationships.banned_ip,!this.user||this.user.data.relationships||t?this.user&&t instanceof app.store.models.banned_ips&&(this.user.data.relationships.banned_ips={data:this.user.data.relationships.banned_ips.data.filter((function(n){return n.id!==t.id()}))},this.user.data.attributes.isBanned=0!==this.user.data.relationships.banned_ips.data.length):(this.user.data.relationships.banned_ips.data=[],this.user.data.attributes.isBanned=!1),t&&Array.isArray(t.data)&&(this.bannedIPs=t.data.map((function(t){return t.attributes.address})),this.loading=!1,m.redraw())},a.hide=function(){t.prototype.hide.call(this),this.attrs.redraw||location.reload()},n}(a(5).a))},function(t,n){t.exports=flarum.core.compat["components/Modal"]},function(t,n,a){"use strict";a.d(n,"a",(function(){return o}));var s=a(2),e=a(0),r=a.n(e),i=a(13),o=function(t){function n(){return t.apply(this,arguments)||this}return Object(s.a)(n,t),n.prototype.apiEndpoint=function(){return"/fof/ban-ips"+(this.exists?"/"+this.id():"")},n}(a.n(i)()(r.a,{creator:r.a.hasOne("creator"),user:r.a.hasOne("user"),address:r.a.attribute("address"),reason:r.a.attribute("reason"),createdAt:r.a.attribute("createdAt",r.a.transformDate),deletedAt:r.a.attribute("deletedAt",r.a.transformDate)}))},function(t,n){t.exports=flarum.core.compat["helpers/username"]},function(t,n,a){"use strict";function s(){return(s=Object.assign||function(t){for(var n=1;n (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n
\n \n \n
\n\n {otherUsersBanned\n ? otherUsersBanned.length\n ? Alert.component({\n dismissible: false,\n }, app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n }))\n : Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.forum.modal.ban_ip_no_users'))\n : ''}\n\n {otherUsersBanned &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n reason: this.reason(),\n userId: this.user.id(),\n };\n\n if (this.banOption() === 'only') {\n attrs.address = this.post.ipAddress();\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/ban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => app.store.pushPayload(res).forEach(this.done.bind(this)))\n .then(this.hide.bind(this))\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') data.ip = this.address || this.post.ipAddress();\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users/${this.user.id()}`,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n this.otherUsers[this.banOption()] = res.data.map((e) => app.store.pushObject(e)).filter((e) => e.bannedIPs().length === 0);\n this.loading = false;\n })\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n const obj = {\n type: 'banned_ips',\n id: bannedIP.id(),\n };\n\n if (this.post) {\n this.post.data.relationships.banned_ip = {\n data: obj,\n };\n }\n\n if (!this.user.data.relationships.banned_ips)\n this.user.data.relationships.banned_ips = {\n data: [],\n };\n\n this.user.data.relationships.banned_ips.data.push(obj);\n this.user.data.attributes.isBanned = true;\n\n app.store.pushObject(this.user.data);\n }\n}\n","module.exports = flarum.core.compat['utils/Stream'];","import Button from 'flarum/components/Button';\nimport Alert from 'flarum/components/Alert';\nimport punctuateSeries from 'flarum/helpers/punctuateSeries';\nimport username from 'flarum/helpers/username';\n\nimport BanIPModal from './BanIPModal';\n\nexport default class UnbanIPModal extends BanIPModal {\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.unban_title');\n }\n\n content() {\n const otherUsers = this.otherUsers[this.banOption()];\n const usernames = otherUsers && otherUsers.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n if (this.bannedIPs) {\n return (\n
\n {Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.lib.modal.unbanned_ips', { ips: punctuateSeries(this.bannedIPs) }))}\n
\n );\n }\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.unban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n {otherUsers\n ? otherUsers.length\n ? Alert.component({\n dismissible: false,\n }, app.translator.transChoice('fof-ban-ips.lib.modal.unban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n }))\n : Alert.component({\n dismissible: false,\n type: 'success',\n }, app.translator.trans('fof-ban-ips.lib.modal.unban_ip_no_users'))\n : ''}\n\n {otherUsers &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {};\n\n if (this.banOption() === 'only') {\n attrs.address = this.address || this.post.ipAddress();\n\n const bannedIP = this.post ? this.post.bannedIP() : app.store.getBy('banned_ips', 'address', this.address);\n\n bannedIP.delete().then(this.done.bind(this, bannedIP)).catch(this.onerror.bind(this)).then(this.hide.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/unban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then(this.done.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.hide.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') {\n data.ip = this.address || this.post.ipAddress();\n data.skipValidation = true;\n }\n\n let url = `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`;\n\n if (this.user) url += `/${this.user.id()}`;\n\n app.request({\n params: data,\n url: url,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n const data = app.store.pushPayload(res);\n\n this.otherUsers[this.banOption()] = data.filter((e) => e.bannedIPs().length === 1);\n this.loading = false;\n\n m.redraw();\n })\n .catch(() => { })\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n this.loading = false;\n\n if (this.post) delete this.post.data.relationships.banned_ip;\n\n if (this.user && !this.user.data.relationships && !bannedIP) {\n this.user.data.relationships.banned_ips.data = [];\n this.user.data.attributes.isBanned = false;\n } else if (this.user && bannedIP instanceof app.store.models.banned_ips) {\n this.user.data.relationships.banned_ips = {\n data: this.user.data.relationships.banned_ips.data.filter((e) => e.id !== bannedIP.id()),\n };\n this.user.data.attributes.isBanned = this.user.data.relationships.banned_ips.data.length !== 0;\n }\n\n if (bannedIP && Array.isArray(bannedIP.data)) {\n this.bannedIPs = bannedIP.data.map((b) => b.attributes.address);\n this.loading = false;\n\n m.redraw();\n }\n }\n\n hide() {\n super.hide();\n\n if (!this.attrs.redraw) {\n location.reload();\n }\n }\n}\n","module.exports = flarum.core.compat['components/Modal'];","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class BannedIP extends mixin(Model, {\n creator: Model.hasOne('creator'),\n user: Model.hasOne('user'),\n address: Model.attribute('address'),\n reason: Model.attribute('reason'),\n createdAt: Model.attribute('createdAt', Model.transformDate),\n deletedAt: Model.attribute('deletedAt', Model.transformDate),\n}) {\n apiEndpoint() {\n return `/fof/ban-ips${this.exists ? `/${this.id()}` : ''}`;\n }\n}\n","module.exports = flarum.core.compat['helpers/username'];","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","module.exports = flarum.core.compat['utils/mixin'];","import BanIPModal from './components/BanIPModal';\nimport UnbanIPModal from './components/UnbanIPModal';\nimport BannedIP from './models/BannedIP';\n\nexport default {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/UnbanIPModal': UnbanIPModal,\n 'fof/ban-ips/models/BannedIP': BannedIP,\n};\n","module.exports = flarum.core;","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['utils/PostControls'];","module.exports = flarum.core.compat['utils/UserControls'];","module.exports = flarum.core.compat['models/User'];","module.exports = flarum.core.compat['components/Badge'];","import Model from 'flarum/Model';\n\nimport addBanIPControl from './addBanIPControl';\nimport BannedIP from '../common/models/BannedIP';\nimport addBannedBadge from './addBannedBadge';\n\napp.initializers.add('fof/ban-ips', () => {\n app.store.models.posts.prototype.canBanIP = Model.attribute('canBanIP');\n app.store.models.posts.prototype.ipAddress = Model.attribute('ipAddress');\n app.store.models.posts.prototype.bannedIP = Model.hasOne('banned_ip');\n\n app.store.models.users.prototype.canBanIP = Model.attribute('canBanIP');\n app.store.models.users.prototype.isBanned = Model.attribute('isBanned');\n app.store.models.users.prototype.bannedIPs = Model.hasMany('banned_ips');\n\n app.store.models.banned_ips = BannedIP;\n\n addBanIPControl();\n addBannedBadge();\n});\n\n// Expose compat API\nimport extCompat from '../common/compat';\nimport { compat } from '@flarum/core/forum';\n\nObject.assign(compat, extCompat);\n","import { extend } from 'flarum/extend';\nimport PostControls from 'flarum/utils/PostControls';\nimport UserControls from 'flarum/utils/UserControls';\nimport Button from 'flarum/components/Button';\n\nimport BanIPModal from '../common/components/BanIPModal';\nimport UnbanIPModal from '../common/components/UnbanIPModal';\n\nexport default () => {\n extend(PostControls, 'userControls', function (items, post) {\n if (!post || !post.user()) return;\n\n const isBanned = post.user().isBanned();\n const prefix = isBanned ? 'un' : '';\n\n // Removes ability to ban thyself and also does permission check.\n if (!post.canBanIP() || post.isHidden() || post.user() === app.session.user || post.contentType() !== 'comment') return;\n\n items.add(\n `${prefix}ban`,\n Button.component({\n icon: 'fas fa-gavel',\n onclick: () => app.modal.show(isBanned ? UnbanIPModal : BanIPModal, { post }),\n }, app.translator.trans(`fof-ban-ips.forum.${prefix}ban_ip_button`))\n );\n });\n\n extend(UserControls, 'moderationControls', function (items, user) {\n if (!user.canBanIP() || user === app.session.user) return;\n\n const isBanned = user.isBanned();\n const prefix = isBanned ? 'un' : '';\n\n items.add(\n `${prefix}ban`,\n Button.component({\n icon: 'fas fa-gavel',\n onclick: () => app.modal.show(isBanned ? UnbanIPModal : BanIPModal, { post }),\n }, app.translator.trans(`fof-ban-ips.forum.user_controls.${prefix}ban_button`))\n );\n });\n};\n","import { extend } from 'flarum/extend';\nimport User from 'flarum/models/User';\nimport Badge from 'flarum/components/Badge';\n\nexport default () => {\n extend(User.prototype, 'badges', function (items) {\n if (this.isBanned()) {\n items.add(\n 'banned',\n Badge.component({\n icon: 'fas fa-gavel',\n type: 'banned',\n label: app.translator.trans('fof-ban-ips.forum.user_badge.banned_tooltip'),\n })\n );\n }\n });\n};\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@fof/ban-ips/webpack/bootstrap","webpack://@fof/ban-ips/external \"flarum.core.compat['common/Model']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Button']\"","webpack://@fof/ban-ips/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/ban-ips/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/helpers/punctuateSeries']\"","webpack://@fof/ban-ips/./src/common/components/BanIPModal.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/utils/Stream']\"","webpack://@fof/ban-ips/./src/common/components/UnbanIPModal.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/ban-ips/./src/common/models/BannedIP.js","webpack://@fof/ban-ips/external \"flarum.core.compat['common/app']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/helpers/username']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/utils/mixin']\"","webpack://@fof/ban-ips/./src/common/compat.js","webpack://@fof/ban-ips/external \"flarum.core\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/extend']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['forum/utils/PostControls']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['forum/utils/UserControls']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/models/User']\"","webpack://@fof/ban-ips/external \"flarum.core.compat['common/components/Badge']\"","webpack://@fof/ban-ips/./src/forum/index.js","webpack://@fof/ban-ips/./src/forum/addBanIPControl.js","webpack://@fof/ban-ips/./src/forum/addBannedBadge.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","constructor","BanIPModal","oninit","vnode","this","address","attrs","post","user","bannedIP","app","store","getBy","banOptions","ipAddress","push","banOption","Stream","reason","otherUsers","loading","className","title","translator","trans","content","otherUsersBanned","usernames","map","u","displayName","type","id","checked","onclick","htmlFor","ip","bidi","length","Alert","component","dismissible","transChoice","users","punctuateSeries","onsubmit","e","preventDefault","getOtherUsers","userId","createRecord","save","then","hide","onerror","loaded","request","body","data","attributes","url","forum","attribute","apiEndpoint","method","errorHandler","res","pushPayload","forEach","done","params","pushObject","filter","bannedIPs","obj","relationships","banned_ip","banned_ips","isBanned","Modal","UnbanIPModal","ips","skipValidation","redraw","models","Array","isArray","b","location","reload","BannedIP","exists","mixin","Model","creator","hasOne","createdAt","transformDate","deletedAt","initializers","add","posts","canBanIP","hasMany","extend","PostControls","items","prefix","isHidden","session","contentType","Button","icon","modal","show","UserControls","User","Badge","label","assign","extCompat"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,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BAKZH,iBAAOW,IAAc,sBAAsB,SAAUT,EAAOlG,GACxD,GAAKA,EAAK8F,YAAc9F,IAASE,IAAImG,QAAQrG,KAA7C,CAEA,IAAMsE,EAAWtE,EAAKsE,WAChB6B,EAAS7B,EAAW,KAAO,GAEjC4B,EAAMN,IACCO,EADP,MAEII,IAAOvE,UACH,CACIwE,KAAM,eACN9E,QAAS,kBAAMxB,IAAIuG,MAAMC,KAAKpC,EAAWE,IAAe/E,IAAY,CAAEM,cAE1EG,IAAIa,WAAWC,MAAf,mCAAwDmF,EAAxD,oBCtCZH,iBAAOY,IAAKjI,UAAW,UAAU,SAAUuH,GACnCtG,KAAK0E,YACL4B,EAAMN,IACF,SACAiB,IAAM7E,UAAU,CACZwE,KAAM,eACNjF,KAAM,SACNuF,MAAO5G,IAAIa,WAAWC,MAAM,wDFahDvD,OAAOsJ,OAAO9H,SAAQ+H","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 26);\n","module.exports = flarum.core.compat['common/Model'];","module.exports = flarum.core.compat['common/components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","module.exports = flarum.core.compat['common/components/Alert'];","module.exports = flarum.core.compat['common/helpers/punctuateSeries'];","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport Stream from 'flarum/common/utils/Stream';\nimport punctuateSeries from 'flarum/common/helpers/punctuateSeries';\n\nexport default class BanIPModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.address = this.attrs.address;\n this.post = this.attrs.post;\n this.user = this.attrs.user || (this.post && this.post.user());\n\n if (!this.user && this.address) {\n const bannedIP = app.store.getBy('banned_ips', 'address', this.address);\n\n if (bannedIP) this.user = bannedIP.user();\n }\n\n this.banOptions = [];\n\n if ((this.post && this.post.ipAddress()) || this.address) this.banOptions.push('only');\n if (this.user) this.banOptions.push('all');\n\n this.banOption = Stream(this.banOptions[0]);\n this.reason = Stream('');\n\n this.otherUsers = {};\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--medium';\n }\n\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.title');\n }\n\n content() {\n const otherUsersBanned = this.otherUsers[this.banOption()];\n const usernames =\n otherUsersBanned && otherUsersBanned.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.ban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n
\n \n \n
\n\n {otherUsersBanned\n ? otherUsersBanned.length\n ? Alert.component(\n {\n dismissible: false,\n },\n app.translator.transChoice('fof-ban-ips.lib.modal.ban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n })\n )\n : Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.forum.modal.ban_ip_no_users')\n )\n : ''}\n\n {otherUsersBanned &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {\n reason: this.reason(),\n userId: this.user.id(),\n };\n\n if (this.banOption() === 'only') {\n attrs.address = this.post.ipAddress();\n\n app.store.createRecord('banned_ips').save(attrs).then(this.hide.bind(this)).catch(this.onerror.bind(this)).then(this.loaded.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/ban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => app.store.pushPayload(res).forEach(this.done.bind(this)))\n .then(this.hide.bind(this))\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') data.ip = this.address || this.post.ipAddress();\n\n app.request({\n params: data,\n url: `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users/${this.user.id()}`,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n this.otherUsers[this.banOption()] = res.data.map((e) => app.store.pushObject(e)).filter((e) => e.bannedIPs().length === 0);\n this.loading = false;\n })\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n const obj = {\n type: 'banned_ips',\n id: bannedIP.id(),\n };\n\n if (this.post) {\n this.post.data.relationships.banned_ip = {\n data: obj,\n };\n }\n\n if (!this.user.data.relationships.banned_ips)\n this.user.data.relationships.banned_ips = {\n data: [],\n };\n\n this.user.data.relationships.banned_ips.data.push(obj);\n this.user.data.attributes.isBanned = true;\n\n app.store.pushObject(this.user.data);\n }\n}\n","module.exports = flarum.core.compat['common/utils/Stream'];","import Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport punctuateSeries from 'flarum/common/helpers/punctuateSeries';\nimport username from 'flarum/common/helpers/username';\n\nimport BanIPModal from './BanIPModal';\n\nexport default class UnbanIPModal extends BanIPModal {\n title() {\n return app.translator.trans('fof-ban-ips.lib.modal.unban_title');\n }\n\n content() {\n const otherUsers = this.otherUsers[this.banOption()];\n const usernames = otherUsers && otherUsers.map((u) => (u && u.displayName()) || app.translator.trans('core.lib.username.deleted_text'));\n\n if (this.bannedIPs) {\n return (\n
\n {Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.lib.modal.unbanned_ips', { ips: punctuateSeries(this.bannedIPs) })\n )}\n
\n );\n }\n\n return (\n
\n

{app.translator.trans('fof-ban-ips.lib.modal.unban_ip_confirmation')}

\n\n
\n {this.banOptions.map((key) => (\n
\n \n  \n \n
\n ))}\n
\n\n {otherUsers\n ? otherUsers.length\n ? Alert.component(\n {\n dismissible: false,\n },\n app.translator.transChoice('fof-ban-ips.lib.modal.unban_ip_users', usernames.length, {\n users: punctuateSeries(usernames),\n })\n )\n : Alert.component(\n {\n dismissible: false,\n type: 'success',\n },\n app.translator.trans('fof-ban-ips.lib.modal.unban_ip_no_users')\n )\n : ''}\n\n {otherUsers &&
}\n\n
\n \n
\n
\n );\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n if (typeof this.otherUsers[this.banOption()] === 'undefined') return this.getOtherUsers();\n\n const attrs = {};\n\n if (this.banOption() === 'only') {\n attrs.address = this.address || this.post.ipAddress();\n\n const bannedIP = this.post ? this.post.bannedIP() : app.store.getBy('banned_ips', 'address', this.address);\n\n bannedIP.delete().then(this.done.bind(this, bannedIP)).catch(this.onerror.bind(this)).then(this.hide.bind(this));\n } else if (this.banOption() === 'all') {\n app.request({\n body: {\n data: {\n attributes: attrs,\n },\n },\n url: `${app.forum.attribute('apiUrl')}${this.user.apiEndpoint()}/unban`,\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then(this.done.bind(this))\n .catch(this.onerror.bind(this))\n .then(this.hide.bind(this));\n }\n }\n\n getOtherUsers() {\n const data = {};\n\n if (this.banOption() === 'only') {\n data.ip = this.address || this.post.ipAddress();\n data.skipValidation = true;\n }\n\n let url = `${app.forum.attribute('apiUrl')}/fof/ban-ips/check-users`;\n\n if (this.user) url += `/${this.user.id()}`;\n\n app.request({\n params: data,\n url: url,\n method: 'GET',\n errorHandler: this.onerror.bind(this),\n })\n .then((res) => {\n const data = app.store.pushPayload(res);\n\n this.otherUsers[this.banOption()] = data.filter((e) => e.bannedIPs().length === 1);\n this.loading = false;\n\n m.redraw();\n })\n .catch(() => {})\n .then(this.loaded.bind(this));\n }\n\n done(bannedIP) {\n this.loading = false;\n\n if (this.post) delete this.post.data.relationships.banned_ip;\n\n if (this.user && !this.user.data.relationships && !bannedIP) {\n this.user.data.relationships.banned_ips.data = [];\n this.user.data.attributes.isBanned = false;\n } else if (this.user && bannedIP instanceof app.store.models.banned_ips) {\n this.user.data.relationships.banned_ips = {\n data: this.user.data.relationships.banned_ips.data.filter((e) => e.id !== bannedIP.id()),\n };\n this.user.data.attributes.isBanned = this.user.data.relationships.banned_ips.data.length !== 0;\n }\n\n if (bannedIP && Array.isArray(bannedIP.data)) {\n this.bannedIPs = bannedIP.data.map((b) => b.attributes.address);\n this.loading = false;\n\n m.redraw();\n }\n }\n\n hide() {\n super.hide();\n\n if (!this.attrs.redraw) {\n location.reload();\n }\n }\n}\n","module.exports = flarum.core.compat['common/components/Modal'];","import Model from 'flarum/common/Model';\nimport mixin from 'flarum/common/utils/mixin';\n\nexport default class BannedIP extends mixin(Model, {\n creator: Model.hasOne('creator'),\n user: Model.hasOne('user'),\n address: Model.attribute('address'),\n reason: Model.attribute('reason'),\n createdAt: Model.attribute('createdAt', Model.transformDate),\n deletedAt: Model.attribute('deletedAt', Model.transformDate),\n}) {\n apiEndpoint() {\n return `/fof/ban-ips${this.exists ? `/${this.id()}` : ''}`;\n }\n}\n","module.exports = flarum.core.compat['common/app'];","module.exports = flarum.core.compat['common/helpers/username'];","module.exports = flarum.core.compat['common/utils/mixin'];","import BanIPModal from './components/BanIPModal';\nimport UnbanIPModal from './components/UnbanIPModal';\nimport BannedIP from './models/BannedIP';\n\nexport default {\n 'fof/ban-ips/components/BanIPModal': BanIPModal,\n 'fof/ban-ips/components/UnbanIPModal': UnbanIPModal,\n 'fof/ban-ips/models/BannedIP': BannedIP,\n};\n","module.exports = flarum.core;","module.exports = flarum.core.compat['common/extend'];","module.exports = flarum.core.compat['forum/utils/PostControls'];","module.exports = flarum.core.compat['forum/utils/UserControls'];","module.exports = flarum.core.compat['common/models/User'];","module.exports = flarum.core.compat['common/components/Badge'];","import app from 'flarum/common/app';\nimport Model from 'flarum/common/Model';\nimport addBanIPControl from './addBanIPControl';\nimport BannedIP from '../common/models/BannedIP';\nimport addBannedBadge from './addBannedBadge';\n\napp.initializers.add('fof/ban-ips', () => {\n app.store.models.posts.prototype.canBanIP = Model.attribute('canBanIP');\n app.store.models.posts.prototype.ipAddress = Model.attribute('ipAddress');\n app.store.models.posts.prototype.bannedIP = Model.hasOne('banned_ip');\n\n app.store.models.users.prototype.canBanIP = Model.attribute('canBanIP');\n app.store.models.users.prototype.isBanned = Model.attribute('isBanned');\n app.store.models.users.prototype.bannedIPs = Model.hasMany('banned_ips');\n\n app.store.models.banned_ips = BannedIP;\n\n addBanIPControl();\n addBannedBadge();\n});\n\n// Expose compat API\nimport extCompat from '../common/compat';\nimport { compat } from '@flarum/core/forum';\n\nObject.assign(compat, extCompat);\n","import { extend } from 'flarum/common/extend';\nimport PostControls from 'flarum/forum/utils/PostControls';\nimport UserControls from 'flarum/forum/utils/UserControls';\nimport Button from 'flarum/common/components/Button';\n\nimport BanIPModal from '../common/components/BanIPModal';\nimport UnbanIPModal from '../common/components/UnbanIPModal';\n\nexport default () => {\n extend(PostControls, 'userControls', function (items, post) {\n if (!post || !post.user()) return;\n\n const isBanned = post.user().isBanned();\n const prefix = isBanned ? 'un' : '';\n\n // Removes ability to ban thyself and also does permission check.\n if (!post.canBanIP() || post.isHidden() || post.user() === app.session.user || post.contentType() !== 'comment') return;\n\n items.add(\n `${prefix}ban`,\n Button.component(\n {\n icon: 'fas fa-gavel',\n onclick: () => app.modal.show(isBanned ? UnbanIPModal : BanIPModal, { post }),\n },\n app.translator.trans(`fof-ban-ips.forum.${prefix}ban_ip_button`)\n )\n );\n });\n\n extend(UserControls, 'moderationControls', function (items, user) {\n if (!user.canBanIP() || user === app.session.user) return;\n\n const isBanned = user.isBanned();\n const prefix = isBanned ? 'un' : '';\n\n items.add(\n `${prefix}ban`,\n Button.component(\n {\n icon: 'fas fa-gavel',\n onclick: () => app.modal.show(isBanned ? UnbanIPModal : BanIPModal, { post }),\n },\n app.translator.trans(`fof-ban-ips.forum.user_controls.${prefix}ban_button`)\n )\n );\n });\n};\n","import { extend } from 'flarum/common/extend';\nimport User from 'flarum/common/models/User';\nimport Badge from 'flarum/common/components/Badge';\n\nexport default () => {\n extend(User.prototype, 'badges', function (items) {\n if (this.isBanned()) {\n items.add(\n 'banned',\n Badge.component({\n icon: 'fas fa-gavel',\n type: 'banned',\n label: app.translator.trans('fof-ban-ips.forum.user_badge.banned_tooltip'),\n })\n );\n }\n });\n};\n"],"sourceRoot":""} \ No newline at end of file