generated from alecodes/base-template
fead: expand archive options
add an option to select how to archive the entries add an option for what entries to archive change the concurrentcy limit to a semaphore instead of a ticker
This commit is contained in:
parent
1788241cd5
commit
b0506c3eab
9 changed files with 99 additions and 72 deletions
|
|
@ -52,6 +52,18 @@ func (ld *Linkding) Archive(url string) error {
|
|||
TagNames: bookmark.TagNames,
|
||||
}
|
||||
|
||||
switch ld.ServiceConfig.Method {
|
||||
case ServiceArchiveMethodArchive:
|
||||
payload.IsArchived = true
|
||||
case ServiceArchiveMethodSeen:
|
||||
payload.Unread = false
|
||||
case ServiceArchiveMethodBoth:
|
||||
payload.Unread = false
|
||||
payload.IsArchived = true
|
||||
default:
|
||||
return fmt.Errorf("Archive method is invalid")
|
||||
}
|
||||
|
||||
if payload.TagNames == nil {
|
||||
payload.TagNames = []string{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package service
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ServiceOption string
|
||||
|
||||
|
|
@ -8,11 +10,21 @@ const (
|
|||
ServiceLinkding ServiceOption = "linkding"
|
||||
)
|
||||
|
||||
type ServiceArchiveMethod string
|
||||
|
||||
const (
|
||||
ServiceArchiveMethodSeen = "seen"
|
||||
ServiceArchiveMethodArchive = "archive"
|
||||
ServiceArchiveMethodBoth = "both"
|
||||
)
|
||||
|
||||
type ServiceConfig struct {
|
||||
Service ServiceOption
|
||||
Host string
|
||||
User string
|
||||
Token string
|
||||
Service ServiceOption
|
||||
Host string
|
||||
User string
|
||||
Token string
|
||||
Method ServiceArchiveMethod
|
||||
MaxRequests uint8
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue