| 144 | @param('highlight', Types.Boolean) |
| 145 | @param('pin', Types.Boolean) |
| 146 | async post( |
| 147 | domainId: string, type: string, title: string, |
| 148 | content: string, highlight = false, pin = false, |
| 149 | ) { |
| 150 | await this.limitRate('add_discussion', 3600, 60); |
| 151 | if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_DISCUSSION); |
| 152 | if (pin) this.checkPerm(PERM.PERM_PIN_DISCUSSION); |
| 153 | const hidden = this.vnode.hidden ?? false; |
| 154 | const did = await discussion.add( |
| 155 | domainId, typeMapper[type], this.vnode.id, this.user._id, |
| 156 | title, content, this.request.ip, highlight, pin, hidden, |
| 157 | ); |
| 158 | this.response.body = { did }; |
| 159 | this.response.redirect = this.url('discussion_detail', { did }); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | class DiscussionDetailHandler extends DiscussionHandler { |