Fix topic node name for DiscuzX migration.

This commit is contained in:
Gucheng Wang 2021-12-04 14:56:41 +08:00
parent 7ffc0c78cf
commit b77726953a
1 changed files with 12 additions and 4 deletions

View File

@ -66,10 +66,14 @@ func getTopicFromThread(thread *Thread, forum *Forum, classMap map[int]*Class) *
state = "Draft"
}
nodeName := strconv.Itoa(thread.Fid)
nodeId := strconv.Itoa(thread.Fid)
tabId := ""
if forum != nil {
nodeName = forum.Name
nodeId = forum.Name
if forum.Type == "group" || forum.Parent == nil {
return nil
}
parentForum := forum.Parent
if parentForum.Parent != nil {
@ -83,8 +87,8 @@ func getTopicFromThread(thread *Thread, forum *Forum, classMap map[int]*Class) *
topic := &object.Topic{
Id: thread.Tid,
Author: thread.Author,
NodeId: nodeName,
NodeName: nodeName,
NodeId: nodeId,
NodeName: nodeId,
TabId: tabId,
Title: thread.Subject,
CreatedTime: getTimeFromUnixSeconds(thread.Dateline),
@ -214,6 +218,10 @@ func getTopicAndReplies(thread *Thread, forum *Forum, classMap map[int]*Class) (
}
topic := getTopicFromThread(thread, forum, classMap)
if topic == nil {
// thread doesn't belong to any forum, ignore it
return nil, nil
}
replies := []*object.Reply{}
for i, post := range thread.Posts {