summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/feed/cache_v1.go4
-rw-r--r--internal/feed/item.go11
-rw-r--r--internal/feed/mail.go1
-rw-r--r--internal/feed/parse.go4
4 files changed, 15 insertions, 5 deletions
diff --git a/internal/feed/cache_v1.go b/internal/feed/cache_v1.go
index 9a6de50..e2562c3 100644
--- a/internal/feed/cache_v1.go
+++ b/internal/feed/cache_v1.go
@@ -6,6 +6,8 @@ import (
"strconv"
"time"
+ "github.com/google/uuid"
+
"github.com/Necoro/feed2imap-go/pkg/log"
"github.com/Necoro/feed2imap-go/pkg/util"
)
@@ -46,7 +48,7 @@ type cachedItem struct {
UpdatedDate time.Time
UpdatedCache time.Time
Hash itemHash
- ID string
+ ID uuid.UUID
}
func (item cachedItem) String() string {
diff --git a/internal/feed/item.go b/internal/feed/item.go
index 5c67784..b8fb7f7 100644
--- a/internal/feed/item.go
+++ b/internal/feed/item.go
@@ -1,8 +1,10 @@
package feed
import (
+ "encoding/base64"
"fmt"
+ "github.com/google/uuid"
"github.com/mmcdole/gofeed"
"github.com/Necoro/feed2imap-go/pkg/config"
@@ -22,7 +24,7 @@ type item struct {
updateOnly bool
reasons []string
images []feedImage
- itemId string
+ itemId uuid.UUID
}
// Creator returns the name of the creating author.
@@ -54,6 +56,11 @@ func (item *item) defaultEmail() string {
return item.feed.Global.DefaultEmail
}
+func (item *item) id() string {
+ idStr := base64.RawURLEncoding.EncodeToString(item.itemId[:])
+ return item.feed.cached.ID() + "#" + idStr
+}
+
func (item *item) messageId() string {
- return fmt.Sprintf("<feed#%s#%s@%s>", item.feed.cached.ID(), item.itemId, config.Hostname())
+ return fmt.Sprintf("<feed#%s@%s>", item.id(), config.Hostname())
}
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index 41a4cbd..8bb9846 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -55,6 +55,7 @@ func (item *item) buildHeader() message.Header {
h.SetAddressList("To", item.toAddress())
h.Set("X-Feed2Imap-Version", config.Version())
h.Set("X-Feed2Imap-Reason", strings.Join(item.reasons, ","))
+ h.Set("X-Feed2Imap-Item", item.id())
h.Set("Message-Id", item.messageId())
{ // date
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index dfb447a..1ba90fd 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -7,7 +7,7 @@ import (
"net/http"
"time"
- "github.com/lithammer/shortuuid"
+ "github.com/google/uuid"
"github.com/mmcdole/gofeed"
"github.com/Necoro/feed2imap-go/pkg/log"
@@ -56,7 +56,7 @@ func (feed *Feed) parse() error {
feed.feed = parsedFeed
feed.items = make([]item, len(parsedFeed.Items))
for idx, feedItem := range parsedFeed.Items {
- feed.items[idx] = item{Feed: parsedFeed, Item: feedItem, itemId: shortuuid.New(), feed: feed}
+ feed.items[idx] = item{Feed: parsedFeed, Item: feedItem, itemId: uuid.New(), feed: feed}
}
return nil
}