mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
refactor(googlereader): rename stream suffix constants for clarity
This commit is contained in:
parent
0d5f4a710f
commit
4679691c94
3 changed files with 32 additions and 34 deletions
|
@ -71,12 +71,12 @@ func checkAndSimplifyTags(addTags []Stream, removeTags []Stream) (map[StreamType
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
case ReadStream:
|
case ReadStream:
|
||||||
if _, ok := tags[KeptUnreadStream]; ok {
|
if _, ok := tags[KeptUnreadStream]; ok {
|
||||||
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnread, read)
|
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnreadStreamSuffix, readStreamSuffix)
|
||||||
}
|
}
|
||||||
tags[ReadStream] = true
|
tags[ReadStream] = true
|
||||||
case KeptUnreadStream:
|
case KeptUnreadStream:
|
||||||
if _, ok := tags[ReadStream]; ok {
|
if _, ok := tags[ReadStream]; ok {
|
||||||
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnread, read)
|
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnreadStreamSuffix, readStreamSuffix)
|
||||||
}
|
}
|
||||||
tags[ReadStream] = false
|
tags[ReadStream] = false
|
||||||
case StarredStream:
|
case StarredStream:
|
||||||
|
@ -91,17 +91,17 @@ func checkAndSimplifyTags(addTags []Stream, removeTags []Stream) (map[StreamType
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
case ReadStream:
|
case ReadStream:
|
||||||
if _, ok := tags[ReadStream]; ok {
|
if _, ok := tags[ReadStream]; ok {
|
||||||
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnread, read)
|
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnreadStreamSuffix, readStreamSuffix)
|
||||||
}
|
}
|
||||||
tags[ReadStream] = false
|
tags[ReadStream] = false
|
||||||
case KeptUnreadStream:
|
case KeptUnreadStream:
|
||||||
if _, ok := tags[ReadStream]; ok {
|
if _, ok := tags[ReadStream]; ok {
|
||||||
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnread, read)
|
return nil, fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnreadStreamSuffix, readStreamSuffix)
|
||||||
}
|
}
|
||||||
tags[ReadStream] = true
|
tags[ReadStream] = true
|
||||||
case StarredStream:
|
case StarredStream:
|
||||||
if _, ok := tags[StarredStream]; ok {
|
if _, ok := tags[StarredStream]; ok {
|
||||||
return nil, fmt.Errorf("googlereader: %s should not be supplied for add and remove simultaneously", starred)
|
return nil, fmt.Errorf("googlereader: %s should not be supplied for add and remove simultaneously", starredStreamSuffix)
|
||||||
}
|
}
|
||||||
tags[StarredStream] = false
|
tags[StarredStream] = false
|
||||||
case BroadcastStream, LikeStream:
|
case BroadcastStream, LikeStream:
|
||||||
|
@ -701,9 +701,9 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userReadingList := fmt.Sprintf(userStreamPrefix, userID) + readingList
|
userReadingList := fmt.Sprintf(userStreamPrefix, userID) + readingListStreamSuffix
|
||||||
userRead := fmt.Sprintf(userStreamPrefix, userID) + read
|
userRead := fmt.Sprintf(userStreamPrefix, userID) + readStreamSuffix
|
||||||
userStarred := fmt.Sprintf(userStreamPrefix, userID) + starred
|
userStarred := fmt.Sprintf(userStreamPrefix, userID) + starredStreamSuffix
|
||||||
|
|
||||||
itemIDs, err := parseItemIDsFromRequest(r)
|
itemIDs, err := parseItemIDsFromRequest(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -936,7 +936,7 @@ func (h *handler) tagListHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
result.Tags = make([]subscriptionCategory, 0)
|
result.Tags = make([]subscriptionCategory, 0)
|
||||||
result.Tags = append(result.Tags, subscriptionCategory{
|
result.Tags = append(result.Tags, subscriptionCategory{
|
||||||
ID: fmt.Sprintf(userStreamPrefix, userID) + starred,
|
ID: fmt.Sprintf(userStreamPrefix, userID) + starredStreamSuffix,
|
||||||
})
|
})
|
||||||
for _, category := range categories {
|
for _, category := range categories {
|
||||||
result.Tags = append(result.Tags, subscriptionCategory{
|
result.Tags = append(result.Tags, subscriptionCategory{
|
||||||
|
|
|
@ -14,18 +14,18 @@ const (
|
||||||
userLabelPrefix = "user/%d/label/"
|
userLabelPrefix = "user/%d/label/"
|
||||||
// feedPrefix is the prefix for a feed stream
|
// feedPrefix is the prefix for a feed stream
|
||||||
feedPrefix = "feed/"
|
feedPrefix = "feed/"
|
||||||
// read is the suffix for read stream
|
// readStreamSuffix is the suffix for read stream
|
||||||
read = "read"
|
readStreamSuffix = "read"
|
||||||
// starred is the suffix for starred stream
|
// starredStreamSuffix is the suffix for starred stream
|
||||||
starred = "starred"
|
starredStreamSuffix = "starred"
|
||||||
// readingList is the suffix for reading list stream
|
// readingListStreamSuffix is the suffix for reading list stream
|
||||||
readingList = "reading-list"
|
readingListStreamSuffix = "reading-list"
|
||||||
// keptUnread is the suffix for kept unread stream
|
// keptUnreadStreamSuffix is the suffix for kept unread stream
|
||||||
keptUnread = "kept-unread"
|
keptUnreadStreamSuffix = "kept-unread"
|
||||||
// broadcast is the suffix for broadcast stream
|
// broadcastStreamSuffix is the suffix for broadcast stream
|
||||||
broadcast = "broadcast"
|
broadcastStreamSuffix = "broadcast"
|
||||||
// broadcastFriends is the suffix for broadcast friends stream
|
// broadcastFriendsStreamSuffix is the suffix for broadcast friends stream
|
||||||
broadcastFriends = "broadcast-friends"
|
broadcastFriendsStreamSuffix = "broadcast-friends"
|
||||||
// like is the suffix for like stream
|
// likeStreamSuffix is the suffix for like stream
|
||||||
like = "like"
|
likeStreamSuffix = "like"
|
||||||
)
|
)
|
||||||
|
|
|
@ -74,30 +74,28 @@ func getStream(streamID string, userID int64) (Stream, error) {
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(streamID, feedPrefix):
|
case strings.HasPrefix(streamID, feedPrefix):
|
||||||
return Stream{Type: FeedStream, ID: strings.TrimPrefix(streamID, feedPrefix)}, nil
|
return Stream{Type: FeedStream, ID: strings.TrimPrefix(streamID, feedPrefix)}, nil
|
||||||
case strings.HasPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID)),
|
case strings.HasPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID)), strings.HasPrefix(streamID, streamPrefix):
|
||||||
strings.HasPrefix(streamID, streamPrefix):
|
|
||||||
id := strings.TrimPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID))
|
id := strings.TrimPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID))
|
||||||
id = strings.TrimPrefix(id, streamPrefix)
|
id = strings.TrimPrefix(id, streamPrefix)
|
||||||
switch id {
|
switch id {
|
||||||
case read:
|
case readStreamSuffix:
|
||||||
return Stream{ReadStream, ""}, nil
|
return Stream{ReadStream, ""}, nil
|
||||||
case starred:
|
case starredStreamSuffix:
|
||||||
return Stream{StarredStream, ""}, nil
|
return Stream{StarredStream, ""}, nil
|
||||||
case readingList:
|
case readingListStreamSuffix:
|
||||||
return Stream{ReadingListStream, ""}, nil
|
return Stream{ReadingListStream, ""}, nil
|
||||||
case keptUnread:
|
case keptUnreadStreamSuffix:
|
||||||
return Stream{KeptUnreadStream, ""}, nil
|
return Stream{KeptUnreadStream, ""}, nil
|
||||||
case broadcast:
|
case broadcastStreamSuffix:
|
||||||
return Stream{BroadcastStream, ""}, nil
|
return Stream{BroadcastStream, ""}, nil
|
||||||
case broadcastFriends:
|
case broadcastFriendsStreamSuffix:
|
||||||
return Stream{BroadcastFriendsStream, ""}, nil
|
return Stream{BroadcastFriendsStream, ""}, nil
|
||||||
case like:
|
case likeStreamSuffix:
|
||||||
return Stream{LikeStream, ""}, nil
|
return Stream{LikeStream, ""}, nil
|
||||||
default:
|
default:
|
||||||
return Stream{NoStream, ""}, fmt.Errorf("googlereader: unknown stream with id: %s", id)
|
return Stream{NoStream, ""}, fmt.Errorf("googlereader: unknown stream with id: %s", id)
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID)),
|
case strings.HasPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID)), strings.HasPrefix(streamID, labelPrefix):
|
||||||
strings.HasPrefix(streamID, labelPrefix):
|
|
||||||
id := strings.TrimPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID))
|
id := strings.TrimPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID))
|
||||||
id = strings.TrimPrefix(id, labelPrefix)
|
id = strings.TrimPrefix(id, labelPrefix)
|
||||||
return Stream{LabelStream, id}, nil
|
return Stream{LabelStream, id}, nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue