Skip to content

Commit

Permalink
fix(source): anonymous sender. close #10
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Aug 1, 2022
1 parent 49d2997 commit a1906df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,22 @@ func index(src string, chatID int64, _search storage.Search) error {
}
}

if !strings.HasPrefix(msg.From, "user") {
// user: real user, channel: anonymous user
if !strings.HasPrefix(msg.From, "user") && !strings.HasPrefix(msg.From, "channel") {
continue
}

sender := strings.TrimPrefix(msg.From, "user")
sender = strings.TrimPrefix(sender, "channel")

if text != "" {
items = append(items, &search.Item{
ID: keygen.SearchMsgID(chatID, msg.ID),
Data: &models.SearchMsg{
ID: strconv.Itoa(msg.ID),
Chat: strconv.FormatInt(chatID, 10),
Text: strings.ReplaceAll(text, "\n", " "),
Sender: strings.TrimPrefix(msg.From, "user"),
Sender: sender,
Date: msg.Time,
},
})
Expand Down

0 comments on commit a1906df

Please sign in to comment.