| 135 | class BlogDetailHandler extends BlogHandler { |
| 136 | @param('did', Types.ObjectId) |
| 137 | async get({ domainId }, did: ObjectId) { |
| 138 | const dsdoc = this.user.hasPriv(PRIV.PRIV_USER_PROFILE) |
| 139 | ? await BlogModel.getStatus(did, this.user._id) |
| 140 | : null; |
| 141 | const udoc = await UserModel.getById(domainId, this.ddoc!.owner); |
| 142 | if (!dsdoc?.view) { |
| 143 | await Promise.all([ |
| 144 | BlogModel.inc(did, 'views', 1), |
| 145 | BlogModel.setStatus(did, this.user._id, { view: true }), |
| 146 | ]); |
| 147 | } |
| 148 | this.response.template = 'blog_detail.html'; |
| 149 | this.response.body = { |
| 150 | ddoc: this.ddoc, dsdoc, udoc, |
| 151 | }; |
| 152 | } |
| 153 | |
| 154 | async post() { |
| 155 | this.checkPriv(PRIV.PRIV_USER_PROFILE); |