Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06e6ad2

Browse files
committed
bugfix
1 parent 4086363 commit 06e6ad2

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/logic/topic.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,29 @@ func (self TopicLogic) Publish(ctx context.Context, me *model.Me, form url.Value
4949

5050
_, err = self.Modify(ctx, me, form)
5151
if err != nil {
52-
objLog.Errorln("Publish Topic modif error:", err)
52+
objLog.Errorln("Publish Topic modify error:", err)
5353
return
5454
}
5555

5656
nid := goutils.MustInt(form.Get("nid"))
57-
if nid != topic.Nid {
58-
DefaultFeed.modifyTopicNode(tid, nid)
59-
}
57+
58+
go func() {
59+
// 不是作者自己修改,且是调整节点,扣除铜币
60+
if topic.Uid != me.Uid && topic.Nid != nid {
61+
node := DefaultNode.FindOne(nid)
62+
award := -500
63+
if node.ShowIndex {
64+
award = -30
65+
}
66+
desc := fmt.Sprintf(`主题节点被管理员调整为 <a href="/go/%s">%s</a>`, node.Ename, node.Name)
67+
user := DefaultUser.FindOne(ctx, "uid", topic.Uid)
68+
DefaultUserRich.IncrUserRich(user, model.MissionTypeModify, award, desc)
69+
}
70+
71+
if nid != topic.Nid {
72+
DefaultFeed.modifyTopicNode(tid, nid)
73+
}
74+
}()
6075
} else {
6176
usernames := form.Get("usernames")
6277
form.Del("usernames")
@@ -392,7 +407,7 @@ func (TopicLogic) FindHotNodes(ctx context.Context) []map[string]interface{} {
392407
return nil
393408
}
394409

395-
nids := make([]int, 0, hotNum)
410+
nids := make([]int, 0, 15)
396411
for rows.Next() {
397412
var nid, topicnum int
398413
err = rows.Scan(&nid, &topicnum)
@@ -407,7 +422,8 @@ func (TopicLogic) FindHotNodes(ctx context.Context) []map[string]interface{} {
407422
nodes := make([]map[string]interface{}, 0, hotNum)
408423

409424
topicNodes := GetNodesByNids(nids)
410-
for _, topicNode := range topicNodes {
425+
for _, nid := range nids {
426+
topicNode := topicNodes[nid]
411427
if !topicNode.ShowIndex {
412428
continue
413429
}

0 commit comments

Comments
 (0)