diff --git a/search/Text 2 Hash.go b/search/Text 2 Hash.go index db4ff09..4a51cb9 100644 --- a/search/Text 2 Hash.go +++ b/search/Text 2 Hash.go @@ -21,7 +21,7 @@ func text2Hashes(text string, hashes map[[32]byte]string) { if unicode.IsSpace(char) { return true } - return strings.ContainsAny(string(char), "+-._()[],") + return strings.ContainsAny(string(char), "+-._()[],–") }) for _, word := range words { diff --git a/webapi/Search Dispatch.go b/webapi/Search Dispatch.go index 9c4f259..8e24df5 100644 --- a/webapi/Search Dispatch.go +++ b/webapi/Search Dispatch.go @@ -10,6 +10,7 @@ import ( "time" "github.com/PeernetOfficial/core" + "github.com/PeernetOfficial/core/blockchain" ) func (api *WebapiInstance) dispatchSearch(input SearchRequest) (job *SearchJob) { @@ -44,16 +45,20 @@ resultLoop: continue } - // new result - newFile := blockRecordFileToAPI(file) - // Deduplicate based on file hash from the same peer. for n := range job.AllFiles { - if bytes.Equal(job.AllFiles[n].Hash, newFile.Hash) && bytes.Equal(job.AllFiles[n].NodeID, newFile.NodeID) { + if bytes.Equal(job.AllFiles[n].Hash, file.Hash) && bytes.Equal(job.AllFiles[n].NodeID, file.NodeID) { continue resultLoop } } + if peer := core.NodelistLookup(file.NodeID); peer != nil { + file.Tags = append(file.Tags, blockchain.TagFromNumber(blockchain.TagSharedByCount, 1)) + } + + // new result + newFile := blockRecordFileToAPI(file) + job.Files = append(job.Files, &newFile) job.AllFiles = append(job.AllFiles, &newFile) job.requireSort = true diff --git a/webapi/Shared Recent.go b/webapi/Shared Recent.go index c7aaa33..ced5bce 100644 --- a/webapi/Shared Recent.go +++ b/webapi/Shared Recent.go @@ -39,6 +39,8 @@ func queryRecentShared(backend *core.Backend, fileType int, limitPeer, limitTota for _, record := range blockDecoded.RecordsDecoded { if file, ok := record.(blockchain.BlockRecordFile); ok && isFileTypeMatchBlock(&file, fileType) { + file.Tags = append(file.Tags, blockchain.TagFromNumber(blockchain.TagSharedByCount, 1)) + // found a new file! append. if filesFromPeer < limitPeer { files = append(files, file)