-
Notifications
You must be signed in to change notification settings - Fork 236
/
QuestionController.java
executable file
·560 lines (525 loc) · 21 KB
/
QuestionController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
/*
* Copyright 2013-2022 Erudika. https://erudika.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For issues and patches go to: https://github.com/erudika
*/
package com.erudika.scoold.controllers;
import com.erudika.para.client.ParaClient;
import com.erudika.para.core.Address;
import com.erudika.para.core.ParaObject;
import com.erudika.para.core.User;
import com.erudika.para.core.utils.Pager;
import com.erudika.para.core.utils.Para;
import com.erudika.para.core.utils.ParaObjectUtils;
import com.erudika.para.core.utils.Utils;
import com.erudika.scoold.ScooldConfig;
import static com.erudika.scoold.ScooldServer.QUESTIONSLINK;
import static com.erudika.scoold.ScooldServer.SIGNINLINK;
import com.erudika.scoold.core.Post;
import com.erudika.scoold.core.Profile;
import com.erudika.scoold.core.Profile.Badge;
import com.erudika.scoold.core.Question;
import com.erudika.scoold.core.Reply;
import com.erudika.scoold.core.Revision;
import com.erudika.scoold.core.UnapprovedQuestion;
import com.erudika.scoold.core.UnapprovedReply;
import com.erudika.scoold.utils.ScooldUtils;
import com.erudika.scoold.utils.avatars.AvatarFormat;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Produces;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
* @author Alex Bogdanovski [alex@erudika.com]
*/
@Controller
@RequestMapping("/question")
public class QuestionController {
public static final Logger logger = LoggerFactory.getLogger(QuestionController.class);
private static final ScooldConfig CONF = ScooldUtils.getConfig();
private final ScooldUtils utils;
private final ParaClient pc;
@Inject
public QuestionController(ScooldUtils utils) {
this.utils = utils;
this.pc = utils.getParaClient();
}
@GetMapping({"/{id}", "/{id}/{title}", "/{id}/{title}/*"})
public String get(@PathVariable String id, @PathVariable(required = false) String title,
@RequestParam(required = false) String sortby, HttpServletRequest req, HttpServletResponse res, Model model) {
Post showPost = pc.read(id);
if (showPost == null || !ParaObjectUtils.typesMatch(showPost)) {
return "redirect:" + QUESTIONSLINK;
}
Profile authUser = utils.getAuthUser(req);
if (!utils.canAccessSpace(authUser, showPost.getSpace())) {
return "redirect:" + (utils.isDefaultSpacePublic() || utils.isAuthenticated(req) ?
QUESTIONSLINK : SIGNINLINK + "?returnto=" + req.getRequestURI());
} else if (!utils.isDefaultSpace(showPost.getSpace()) && pc.read(utils.getSpaceId(showPost.getSpace())) == null) {
showPost.setSpace(Post.DEFAULT_SPACE);
pc.update(showPost);
}
if (showPost instanceof UnapprovedQuestion && !(utils.isMine(showPost, authUser) || utils.isMod(authUser))) {
return "redirect:" + QUESTIONSLINK;
}
Pager itemcount = utils.getPager("page", req);
itemcount.setSortby("newest".equals(sortby) ? "timestamp" : "votes");
List<Reply> answerslist = getAllAnswers(authUser, showPost, itemcount);
LinkedList<Post> allPosts = new LinkedList<Post>();
allPosts.add(showPost);
allPosts.addAll(answerslist);
utils.fetchProfiles(allPosts);
utils.getComments(allPosts);
utils.updateViewCount(showPost, req, res);
model.addAttribute("path", "question.vm");
model.addAttribute("title", showPost.getTitle());
model.addAttribute("description", Utils.abbreviate(Utils.stripAndTrim(showPost.getBody(), " "), 195));
model.addAttribute("keywords", showPost.getTagsString());
model.addAttribute("itemcount", itemcount);
model.addAttribute("showPost", allPosts.removeFirst());
model.addAttribute("answerslist", allPosts);
model.addAttribute("similarquestions", utils.getSimilarPosts(showPost, new Pager(10)));
model.addAttribute("maxCommentLength", CONF.maxCommentLength());
model.addAttribute("includeGMapsScripts", utils.isNearMeFeatureEnabled());
model.addAttribute("maxCommentLengthError", Utils.formatMessage(utils.getLang(req).get("maxlength"),
CONF.maxCommentLength()));
if (showPost.getAuthor() != null) {
model.addAttribute("ogimage", utils.getFullAvatarURL(showPost.getAuthor(), AvatarFormat.Profile));
}
return "base";
}
@PostMapping("/{id}/edit")
public String edit(@PathVariable String id, @RequestParam(required = false) String title,
@RequestParam(required = false) String body, @RequestParam(required = false) String tags,
@RequestParam(required = false) String location, @RequestParam(required = false) String latlng,
@RequestParam(required = false) String space, HttpServletRequest req, HttpServletResponse res, Model model) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (!utils.canEdit(showPost, authUser) || showPost == null) {
model.addAttribute("post", showPost);
if (utils.isAjaxRequest(req)) {
res.setStatus(400);
return "blank";
} else {
return "redirect:" + req.getRequestURI(); // + "/edit-post-12345" ?
}
}
boolean isQuestion = !showPost.isReply();
Set<String> addedTags = new HashSet<>();
Post beforeUpdate = null;
try {
beforeUpdate = (Post) BeanUtils.cloneBean(showPost);
} catch (Exception ex) {
logger.error(null, ex);
}
// body can be blank
showPost.setBody(body);
showPost.setLocation(location);
showPost.setAuthor(authUser);
if (isQuestion) {
if (StringUtils.length(title) > 2) {
showPost.setTitle(title);
}
addedTags = updateTags(showPost, tags);
updateSpaces(showPost, authUser, space, req);
}
//note: update only happens if something has changed
if (!showPost.equals(beforeUpdate)) {
// create revision manually
if (showPost.hasUpdatedContent(beforeUpdate)) {
Revision.createRevisionFromPost(showPost, false);
}
updatePost(showPost, authUser);
updateLocation(showPost, authUser, location, latlng);
utils.addBadgeOnceAndUpdate(authUser, Badge.EDITOR, true);
utils.sendUpdatedFavTagsNotifications(showPost, new ArrayList<>(addedTags), req);
}
model.addAttribute("post", showPost);
if (utils.isAjaxRequest(req)) {
res.setStatus(200);
res.setContentType("application/json");
try {
res.getWriter().println("{\"url\":\"" + getPostLink(showPost) + "\"}");
} catch (IOException ex) { }
return "blank";
} else {
return "redirect:" + showPost.getPostLink(false, false);
}
}
@PostMapping({"/{id}", "/{id}/{title}", "/{id}/{title}/write"})
public String reply(@PathVariable String id, @PathVariable(required = false) String title,
@RequestParam(required = false) Boolean emailme, HttpServletRequest req,
HttpServletResponse res, Model model) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (authUser == null || showPost == null) {
if (utils.isAjaxRequest(req)) {
res.setStatus(400);
return "base";
} else {
return "redirect:" + QUESTIONSLINK + "/" + id;
}
}
if (emailme != null) {
followPost(showPost, authUser, emailme);
} else if (!showPost.isClosed() && !showPost.isReply()) {
//create new answer
boolean needsApproval = utils.postNeedsApproval(authUser);
Reply answer = utils.populate(req, needsApproval ? new UnapprovedReply() : new Reply(), "body");
Map<String, String> error = utils.validate(answer);
if (!error.containsKey("body") && !StringUtils.isBlank(answer.getBody())) {
answer.setTitle(showPost.getTitle());
answer.setCreatorid(authUser.getId());
answer.setParentid(showPost.getId());
answer.setSpace(showPost.getSpace());
answer.create();
showPost.setAnswercount(showPost.getAnswercount() + 1);
showPost.setLastactivity(System.currentTimeMillis());
if (showPost.getAnswercount() >= CONF.maxRepliesPerPost()) {
showPost.setCloserid("0");
}
// update without adding revisions
pc.update(showPost);
utils.addBadgeAndUpdate(authUser, Badge.EUREKA, answer.getCreatorid().equals(showPost.getCreatorid()));
answer.setAuthor(authUser);
model.addAttribute("showPost", showPost);
model.addAttribute("answerslist", Collections.singletonList(answer));
// send email to the question author
utils.sendReplyNotifications(showPost, answer, req);
model.addAttribute("newpost", getNewAnswerPayload(answer));
} else {
model.addAttribute("error", error);
model.addAttribute("path", "question.vm");
res.setStatus(400);
}
return "reply";
} else {
model.addAttribute("error", "Parent post doesn't exist or cannot have children.");
}
if (utils.isAjaxRequest(req)) {
res.setStatus(200);
return "reply";
} else {
return "redirect:" + QUESTIONSLINK + "/" + id;
}
}
@PostMapping("/{id}/approve")
public String modApprove(@PathVariable String id, HttpServletRequest req) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (utils.isMod(authUser)) {
if (showPost instanceof UnapprovedQuestion) {
showPost.setType(Utils.type(Question.class));
pc.create(showPost);
utils.sendNewPostNotifications(showPost, req);
} else if (showPost instanceof UnapprovedReply) {
showPost.setType(Utils.type(Reply.class));
pc.create(showPost);
}
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/approve/{answerid}")
public String approve(@PathVariable String id, @PathVariable String answerid, HttpServletRequest req) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (!utils.canEdit(showPost, authUser) || showPost == null) {
return "redirect:" + req.getRequestURI();
}
if (utils.canEdit(showPost, authUser) && answerid != null &&
(utils.isMine(showPost, authUser) || utils.isMod(authUser))) {
Reply answer = (Reply) pc.read(answerid);
if (answer != null && answer.isReply()) {
Profile author = pc.read(answer.getCreatorid());
if (author != null && utils.isAuthenticated(req)) {
boolean samePerson = author.equals(authUser);
if (answerid.equals(showPost.getAnswerid())) {
// Answer approved award - UNDO
showPost.setAnswerid("");
if (!samePerson) {
author.removeRep(CONF.answerApprovedRewardAuthor());
authUser.removeRep(CONF.answerApprovedRewardVoter());
pc.updateAll(Arrays.asList(author, authUser));
}
} else {
// Answer approved award - GIVE
showPost.setAnswerid(answerid);
if (!samePerson) {
author.addRep(CONF.answerApprovedRewardAuthor());
authUser.addRep(CONF.answerApprovedRewardVoter());
utils.addBadgeOnce(authUser, Badge.NOOB, true);
pc.updateAll(Arrays.asList(author, authUser));
}
utils.triggerHookEvent("answer.accept",
getAcceptedAnswerPayload(showPost, answer, authUser, author));
}
showPost.update();
}
}
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/close")
public String close(@PathVariable String id, HttpServletRequest req) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (showPost == null) {
return "redirect:" + req.getRequestURI();
}
if (utils.isMod(authUser) && !showPost.isReply()) {
if (showPost.isClosed()) {
showPost.setCloserid("");
} else {
showPost.setCloserid(authUser.getId());
utils.triggerHookEvent("question.close", showPost);
}
showPost.update();
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/restore/{revisionid}")
public String restore(@PathVariable String id, @PathVariable String revisionid, HttpServletRequest req) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (!utils.canEdit(showPost, authUser) || showPost == null) {
return "redirect:" + req.getRequestURI();
}
if (utils.canEdit(showPost, authUser)) {
utils.addBadgeAndUpdate(authUser, Badge.BACKINTIME, true);
showPost.restoreRevisionAndUpdate(revisionid);
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/delete")
public String delete(@PathVariable String id, HttpServletRequest req, Model model) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (!utils.canEdit(showPost, authUser) || showPost == null) {
model.addAttribute("post", showPost);
return "redirect:" + req.getRequestURI();
}
if (!showPost.isReply()) {
if ((utils.isMine(showPost, authUser) && utils.canDelete(showPost, authUser)) || utils.isMod(authUser)) {
showPost.delete();
model.addAttribute("deleted", true);
return "redirect:" + QUESTIONSLINK + "?success=true&code=16";
}
} else if (showPost.isReply()) {
Post parent = pc.read(showPost.getParentid());
if ((utils.isMine(showPost, authUser) && utils.canDelete(showPost, authUser, parent.getAnswerid())) ||
utils.isMod(authUser)) {
parent.setAnswercount(parent.getAnswercount() - 1);
parent.setAnswerid(showPost.getId().equals(parent.getAnswerid()) ? "" : parent.getAnswerid());
parent.update();
showPost.delete();
model.addAttribute("deleted", true);
}
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/deprecate")
public String deprecate(@PathVariable String id, HttpServletRequest req) {
Post showPost = pc.read(id);
Profile authUser = utils.getAuthUser(req);
if (!utils.canEdit(showPost, authUser) || showPost == null) {
return "redirect:" + req.getRequestURI();
}
if (utils.canEdit(showPost, authUser)) {
showPost.setDeprecated(!showPost.getDeprecated());
showPost.update();
}
return "redirect:" + showPost.getPostLink(false, false);
}
@PostMapping("/{id}/merge-into")
public String merge(@PathVariable String id, @RequestParam String id2, HttpServletRequest req) {
Post showPost = pc.read(id);
Post targetPost = pc.read(id2);
Profile authUser = utils.getAuthUser(req);
if (!(utils.canEdit(showPost, authUser) && utils.canEdit(targetPost, authUser)) || showPost == null ||
targetPost == null || showPost.isReply() || targetPost.isReply() || showPost.equals(targetPost)) {
return "redirect:" + req.getRequestURI();
}
if (utils.canEdit(showPost, authUser) && utils.canEdit(targetPost, authUser)) {
if (CONF.mergeQuestionBodies()) {
targetPost.setBody(targetPost.getBody() + "\n\n" + showPost.getBody());
}
targetPost.setAnswercount(targetPost.getAnswercount() + showPost.getAnswercount());
targetPost.setViewcount(targetPost.getViewcount() + showPost.getViewcount());
if (showPost.hasFollowers()) {
for (Map.Entry<String, String> entry : showPost.getFollowers().entrySet()) {
User u = new User(entry.getKey());
u.setEmail(entry.getValue());
targetPost.addFollower(u);
}
}
Pager pager = new Pager(1, "_docid", false, CONF.maxItemsPerPage());
List<Reply> answers;
do {
answers = pc.getChildren(showPost, Utils.type(Reply.class), pager);
for (Reply answer : answers) {
answer.setParentid(targetPost.getId());
answer.setTitle(targetPost.getTitle());
}
pc.createAll(answers); // overwrite
} while (!answers.isEmpty());
targetPost.update();
showPost.delete();
}
return "redirect:" + targetPost.getPostLink(false, false);
}
@GetMapping("/find/{q}")
@Produces("application/json")
public ResponseEntity<List<ParaObject>> findAjax(@PathVariable String q, HttpServletRequest req, HttpServletResponse res) {
if (!utils.isDefaultSpacePublic() && !utils.isAuthenticated(req)) {
res.setStatus(401);
return ResponseEntity.status(401).body(Collections.emptyList());
}
String qs = utils.sanitizeQueryString(q + "*", req);
Pager pager = new Pager(1, "votes", true, 10);
return ResponseEntity.ok(pc.findQuery(Utils.type(Question.class), qs, pager));
}
private void changeSpaceForAllAnswers(Post showPost, String space) {
if (showPost == null || showPost.isReply()) {
return;
}
Pager pager = new Pager(1, "_docid", false, CONF.maxItemsPerPage());
List<Reply> answerslist;
try {
do {
answerslist = pc.getChildren(showPost, Utils.type(Reply.class), pager);
for (Reply reply : answerslist) {
reply.setSpace(space);
}
if (!answerslist.isEmpty()) {
pc.updateAll(answerslist);
Thread.sleep(500);
}
} while (!answerslist.isEmpty());
} catch (InterruptedException ex) {
logger.error(null, ex);
Thread.currentThread().interrupt();
}
}
private List<Reply> getAllAnswers(Profile authUser, Post showPost, Pager itemcount) {
if (showPost == null || showPost.isReply()) {
return Collections.emptyList();
}
List<Reply> answers = new ArrayList<>();
Pager p = new Pager(itemcount.getPage(), itemcount.getLimit());
if (utils.postsNeedApproval() && (utils.isMine(showPost, authUser) || utils.isMod(authUser))) {
answers.addAll(showPost.getUnapprovedAnswers(p));
}
answers.addAll(showPost.getAnswers(itemcount));
itemcount.setCount(itemcount.getCount() + p.getCount());
return answers;
}
private void updatePost(Post showPost, Profile authUser) {
showPost.setLasteditby(authUser.getId());
showPost.setLastedited(System.currentTimeMillis());
if (showPost.isQuestion()) {
showPost.setLastactivity(System.currentTimeMillis());
showPost.update();
} else if (showPost.isReply()) {
Post questionPost = pc.read(showPost.getParentid());
if (questionPost != null) {
showPost.setSpace(questionPost.getSpace());
questionPost.setLastactivity(System.currentTimeMillis());
pc.updateAll(Arrays.asList(showPost, questionPost));
} else {
// create revision here
showPost.update();
}
}
}
private void updateLocation(Post showPost, Profile authUser, String location, String latlng) {
if (!showPost.isReply() && !StringUtils.isBlank(latlng)) {
Address addr = new Address(showPost.getId() + Para.getConfig().separator() + Utils.type(Address.class));
addr.setAddress(location);
addr.setCountry(location);
addr.setLatlng(latlng);
addr.setParentid(showPost.getId());
addr.setCreatorid(authUser.getId());
pc.create(addr);
}
}
private Set<String> updateTags(Post showPost, String tags) {
if (!StringUtils.isBlank(tags)) {
List<String> newTags = Arrays.asList(StringUtils.split(tags, ","));
HashSet<String> addedTags = new HashSet<>(newTags);
addedTags.removeAll(new HashSet<>(Optional.ofNullable(showPost.getTags()).orElse(Collections.emptyList())));
showPost.updateTags(showPost.getTags(), newTags);
return addedTags;
}
return Collections.emptySet();
}
private void updateSpaces(Post showPost, Profile authUser, String space, HttpServletRequest req) {
String validSpace = utils.getValidSpaceIdExcludingAll(authUser,
Optional.ofNullable(space).orElse(showPost.getSpace()), req);
if (utils.canAccessSpace(authUser, validSpace) && validSpace != null
&& !utils.getSpaceId(validSpace).equals(utils.getSpaceId(showPost.getSpace()))) {
showPost.setSpace(validSpace);
changeSpaceForAllAnswers(showPost, validSpace);
}
}
private Map<String, Object> getNewAnswerPayload(Reply answer) {
Map<String, Object> payload = new LinkedHashMap<>(ParaObjectUtils.getAnnotatedFields(answer, false));
payload.put("author", answer == null ? null : answer.getAuthor());
utils.triggerHookEvent("answer.create", payload);
return payload;
}
private Object getAcceptedAnswerPayload(Post showPost, Reply answer, Profile authUser, Profile author) {
Map<String, Object> payload = new LinkedHashMap<>(ParaObjectUtils.getAnnotatedFields(showPost, false));
Map<String, Object> answerPayload = new LinkedHashMap<>(ParaObjectUtils.getAnnotatedFields(answer, false));
answerPayload.put("author", author);
payload.put("children", answerPayload);
payload.put("authUser", authUser);
return payload;
}
private void followPost(Post showPost, Profile authUser, Boolean emailme) {
if (emailme) {
showPost.addFollower(authUser.getUser());
} else {
showPost.removeFollower(authUser.getUser());
}
pc.update(showPost); // update without adding revisions
}
private String getPostLink(Post showPost) {
return showPost.getPostLink(false, false) + (showPost.isQuestion() ? "" : "#post-" + showPost.getId());
}
}