mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
refactor(googlereader): unexport a lot of symbols
This commit is contained in:
parent
92d2ac4f58
commit
0d5f4a710f
6 changed files with 114 additions and 112 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", keptUnread, read)
|
||||||
}
|
}
|
||||||
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", keptUnread, read)
|
||||||
}
|
}
|
||||||
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", keptUnread, read)
|
||||||
}
|
}
|
||||||
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", keptUnread, read)
|
||||||
}
|
}
|
||||||
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", starred)
|
||||||
}
|
}
|
||||||
tags[StarredStream] = false
|
tags[StarredStream] = false
|
||||||
case BroadcastStream, LikeStream:
|
case BroadcastStream, LikeStream:
|
||||||
|
@ -269,12 +269,12 @@ func (h *handler) editTagHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
addTags, err := getStreams(r.PostForm[ParamTagsAdd], userID)
|
addTags, err := getStreams(r.PostForm[paramTagsAdd], userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.ServerError(w, r, err)
|
json.ServerError(w, r, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
removeTags, err := getStreams(r.PostForm[ParamTagsRemove], userID)
|
removeTags, err := getStreams(r.PostForm[paramTagsRemove], userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.ServerError(w, r, err)
|
json.ServerError(w, r, err)
|
||||||
return
|
return
|
||||||
|
@ -407,7 +407,7 @@ func (h *handler) quickAddHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
feedURL := r.Form.Get(ParamQuickAdd)
|
feedURL := r.Form.Get(paramQuickAdd)
|
||||||
if !validator.IsValidURL(feedURL) {
|
if !validator.IsValidURL(feedURL) {
|
||||||
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid URL: %s", feedURL))
|
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid URL: %s", feedURL))
|
||||||
return
|
return
|
||||||
|
@ -456,7 +456,7 @@ func (h *handler) quickAddHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
json.OK(w, r, quickAddResponse{
|
json.OK(w, r, quickAddResponse{
|
||||||
NumResults: 1,
|
NumResults: 1,
|
||||||
Query: newFeed.FeedURL,
|
Query: newFeed.FeedURL,
|
||||||
StreamID: fmt.Sprintf(FeedPrefix+"%d", newFeed.ID),
|
StreamID: fmt.Sprintf(feedPrefix+"%d", newFeed.ID),
|
||||||
StreamName: newFeed.Title,
|
StreamName: newFeed.Title,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -609,20 +609,20 @@ func (h *handler) editSubscriptionHandler(w http.ResponseWriter, r *http.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
streamIds, err := getStreams(r.Form[ParamStreamID], userID)
|
streamIds, err := getStreams(r.Form[paramStreamID], userID)
|
||||||
if err != nil || len(streamIds) == 0 {
|
if err != nil || len(streamIds) == 0 {
|
||||||
json.BadRequest(w, r, errors.New("googlereader: no valid stream IDs provided"))
|
json.BadRequest(w, r, errors.New("googlereader: no valid stream IDs provided"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
newLabel, err := getStream(r.Form.Get(ParamTagsAdd), userID)
|
newLabel, err := getStream(r.Form.Get(paramTagsAdd), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", ParamTagsAdd))
|
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramTagsAdd))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
title := r.Form.Get(ParamTitle)
|
title := r.Form.Get(paramTitle)
|
||||||
action := r.Form.Get(ParamSubscribeAction)
|
action := r.Form.Get(paramSubscribeAction)
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case "subscribe":
|
case "subscribe":
|
||||||
|
@ -649,7 +649,7 @@ func (h *handler) editSubscriptionHandler(w http.ResponseWriter, r *http.Request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Form.Has(ParamTagsAdd) {
|
if r.Form.Has(paramTagsAdd) {
|
||||||
if newLabel.Type != LabelStream {
|
if newLabel.Type != LabelStream {
|
||||||
json.BadRequest(w, r, errors.New("destination must be a label"))
|
json.BadRequest(w, r, errors.New("destination must be a label"))
|
||||||
return
|
return
|
||||||
|
@ -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) + readingList
|
||||||
userRead := fmt.Sprintf(UserStreamPrefix, userID) + Read
|
userRead := fmt.Sprintf(userStreamPrefix, userID) + read
|
||||||
userStarred := fmt.Sprintf(UserStreamPrefix, userID) + Starred
|
userStarred := fmt.Sprintf(userStreamPrefix, userID) + starred
|
||||||
|
|
||||||
itemIDs, err := parseItemIDsFromRequest(r)
|
itemIDs, err := parseItemIDsFromRequest(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -752,7 +752,7 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
||||||
categories := make([]string, 0)
|
categories := make([]string, 0)
|
||||||
categories = append(categories, userReadingList)
|
categories = append(categories, userReadingList)
|
||||||
if entry.Feed.Category.Title != "" {
|
if entry.Feed.Category.Title != "" {
|
||||||
categories = append(categories, fmt.Sprintf(UserLabelPrefix, userID)+entry.Feed.Category.Title)
|
categories = append(categories, fmt.Sprintf(userLabelPrefix, userID)+entry.Feed.Category.Title)
|
||||||
}
|
}
|
||||||
if entry.Status == model.EntryStatusRead {
|
if entry.Status == model.EntryStatusRead {
|
||||||
categories = append(categories, userRead)
|
categories = append(categories, userRead)
|
||||||
|
@ -822,9 +822,9 @@ func (h *handler) disableTagHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
streams, err := getStreams(r.Form[ParamStreamID], userID)
|
streams, err := getStreams(r.Form[paramStreamID], userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", ParamStreamID))
|
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramStreamID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,15 +862,15 @@ func (h *handler) renameTagHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
source, err := getStream(r.Form.Get(ParamStreamID), userID)
|
source, err := getStream(r.Form.Get(paramStreamID), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", ParamStreamID))
|
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramStreamID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
destination, err := getStream(r.Form.Get(ParamDestination), userID)
|
destination, err := getStream(r.Form.Get(paramDestination), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", ParamDestination))
|
json.BadRequest(w, r, fmt.Errorf("googlereader: invalid data in %s", paramDestination))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,11 +936,11 @@ 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) + starred,
|
||||||
})
|
})
|
||||||
for _, category := range categories {
|
for _, category := range categories {
|
||||||
result.Tags = append(result.Tags, subscriptionCategory{
|
result.Tags = append(result.Tags, subscriptionCategory{
|
||||||
ID: fmt.Sprintf(UserLabelPrefix, userID) + category.Title,
|
ID: fmt.Sprintf(userLabelPrefix, userID) + category.Title,
|
||||||
Label: category.Title,
|
Label: category.Title,
|
||||||
Type: "folder",
|
Type: "folder",
|
||||||
})
|
})
|
||||||
|
@ -973,10 +973,10 @@ func (h *handler) subscriptionListHandler(w http.ResponseWriter, r *http.Request
|
||||||
result.Subscriptions = make([]subscription, 0)
|
result.Subscriptions = make([]subscription, 0)
|
||||||
for _, feed := range feeds {
|
for _, feed := range feeds {
|
||||||
result.Subscriptions = append(result.Subscriptions, subscription{
|
result.Subscriptions = append(result.Subscriptions, subscription{
|
||||||
ID: fmt.Sprintf(FeedPrefix+"%d", feed.ID),
|
ID: fmt.Sprintf(feedPrefix+"%d", feed.ID),
|
||||||
Title: feed.Title,
|
Title: feed.Title,
|
||||||
URL: feed.FeedURL,
|
URL: feed.FeedURL,
|
||||||
Categories: []subscriptionCategory{{fmt.Sprintf(UserLabelPrefix, userID) + feed.Category.Title, feed.Category.Title, "folder"}},
|
Categories: []subscriptionCategory{{fmt.Sprintf(userLabelPrefix, userID) + feed.Category.Title, feed.Category.Title, "folder"}},
|
||||||
HTMLURL: feed.SiteURL,
|
HTMLURL: feed.SiteURL,
|
||||||
IconURL: h.feedIconURL(feed),
|
IconURL: h.feedIconURL(feed),
|
||||||
})
|
})
|
||||||
|
@ -1278,14 +1278,14 @@ func (h *handler) markAllAsReadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stream, err := getStream(r.Form.Get(ParamStreamID), userID)
|
stream, err := getStream(r.Form.Get(paramStreamID), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, err)
|
json.BadRequest(w, r, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var before time.Time
|
var before time.Time
|
||||||
if timestampParamValue := r.Form.Get(ParamTimestamp); timestampParamValue != "" {
|
if timestampParamValue := r.Form.Get(paramTimestamp); timestampParamValue != "" {
|
||||||
timestampParsedValue, err := strconv.ParseInt(timestampParamValue, 10, 64)
|
timestampParsedValue, err := strconv.ParseInt(timestampParamValue, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
json.BadRequest(w, r, err)
|
json.BadRequest(w, r, err)
|
||||||
|
|
|
@ -56,7 +56,7 @@ func parseItemID(itemIDValue string) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseItemIDsFromRequest(r *http.Request) ([]int64, error) {
|
func parseItemIDsFromRequest(r *http.Request) ([]int64, error) {
|
||||||
items := r.Form[ParamItemIDs]
|
items := r.Form[paramItemIDs]
|
||||||
if len(items) == 0 {
|
if len(items) == 0 {
|
||||||
return nil, fmt.Errorf("googlereader: no items requested")
|
return nil, fmt.Errorf("googlereader: no items requested")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,36 +4,36 @@
|
||||||
package googlereader // import "miniflux.app/v2/internal/googlereader"
|
package googlereader // import "miniflux.app/v2/internal/googlereader"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ParamItemIDs - name of the parameter with the item ids
|
// paramItemIDs - name of the parameter with the item ids
|
||||||
ParamItemIDs = "i"
|
paramItemIDs = "i"
|
||||||
// ParamStreamID - name of the parameter containing the stream to be included
|
// paramStreamID - name of the parameter containing the stream to be included
|
||||||
ParamStreamID = "s"
|
paramStreamID = "s"
|
||||||
// ParamStreamExcludes - name of the parameter containing streams to be excluded
|
// paramStreamExcludes - name of the parameter containing streams to be excluded
|
||||||
ParamStreamExcludes = "xt"
|
paramStreamExcludes = "xt"
|
||||||
// ParamStreamFilters - name of the parameter containing streams to be included
|
// paramStreamFilters - name of the parameter containing streams to be included
|
||||||
ParamStreamFilters = "it"
|
paramStreamFilters = "it"
|
||||||
// ParamStreamMaxItems - name of the parameter containing number of items per page/max items returned
|
// paramStreamMaxItems - name of the parameter containing number of items per page/max items returned
|
||||||
ParamStreamMaxItems = "n"
|
paramStreamMaxItems = "n"
|
||||||
// ParamStreamOrder - name of the parameter containing the sort criteria
|
// paramStreamOrder - name of the parameter containing the sort criteria
|
||||||
ParamStreamOrder = "r"
|
paramStreamOrder = "r"
|
||||||
// ParamStreamStartTime - name of the parameter containing epoch timestamp, filtering items older than
|
// paramStreamStartTime - name of the parameter containing epoch timestamp, filtering items older than
|
||||||
ParamStreamStartTime = "ot"
|
paramStreamStartTime = "ot"
|
||||||
// ParamStreamStopTime - name of the parameter containing epoch timestamp, filtering items newer than
|
// paramStreamStopTime - name of the parameter containing epoch timestamp, filtering items newer than
|
||||||
ParamStreamStopTime = "nt"
|
paramStreamStopTime = "nt"
|
||||||
// ParamTagsRemove - name of the parameter containing tags (streams) to be removed
|
// paramTagsRemove - name of the parameter containing tags (streams) to be removed
|
||||||
ParamTagsRemove = "r"
|
paramTagsRemove = "r"
|
||||||
// ParamTagsAdd - name of the parameter containing tags (streams) to be added
|
// paramTagsAdd - name of the parameter containing tags (streams) to be added
|
||||||
ParamTagsAdd = "a"
|
paramTagsAdd = "a"
|
||||||
// ParamSubscribeAction - name of the parameter indicating the action to take for subscription/edit
|
// paramSubscribeAction - name of the parameter indicating the action to take for subscription/edit
|
||||||
ParamSubscribeAction = "ac"
|
paramSubscribeAction = "ac"
|
||||||
// ParamTitle - name of the parameter for the title of the subscription
|
// paramTitle - name of the parameter for the title of the subscription
|
||||||
ParamTitle = "t"
|
paramTitle = "t"
|
||||||
// ParamQuickAdd - name of the parameter for a URL being quick subscribed to
|
// paramQuickAdd - name of the parameter for a URL being quick subscribed to
|
||||||
ParamQuickAdd = "quickadd"
|
paramQuickAdd = "quickadd"
|
||||||
// ParamDestination - name of the parameter for the new name of a tag
|
// paramDestination - name of the parameter for the new name of a tag
|
||||||
ParamDestination = "dest"
|
paramDestination = "dest"
|
||||||
// ParamContinuation - name of the parameter for callers to pass to receive the next page of results
|
// paramContinuation - name of the parameter for callers to pass to receive the next page of results
|
||||||
ParamContinuation = "c"
|
paramContinuation = "c"
|
||||||
// ParamStreamType - name of the parameter for unix timestamp
|
// paramTimestamp - name of the parameter for unix timestamp
|
||||||
ParamTimestamp = "ts"
|
paramTimestamp = "ts"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,28 +4,28 @@
|
||||||
package googlereader // import "miniflux.app/v2/internal/googlereader"
|
package googlereader // import "miniflux.app/v2/internal/googlereader"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// StreamPrefix is the prefix for astreams (read/starred/reading list and so on)
|
// streamPrefix is the prefix for streams (read/starred/reading list and so on)
|
||||||
StreamPrefix = "user/-/state/com.google/"
|
streamPrefix = "user/-/state/com.google/"
|
||||||
// UserStreamPrefix is the user specific prefix for streams (read/starred/reading list and so on)
|
// userStreamPrefix is the user specific prefix for streams (read/starred/reading list and so on)
|
||||||
UserStreamPrefix = "user/%d/state/com.google/"
|
userStreamPrefix = "user/%d/state/com.google/"
|
||||||
// LabelPrefix is the prefix for a label stream
|
// labelPrefix is the prefix for a label stream
|
||||||
LabelPrefix = "user/-/label/"
|
labelPrefix = "user/-/label/"
|
||||||
// UserLabelPrefix is the user specific prefix prefix for a label stream
|
// userLabelPrefix is the user specific prefix prefix for a label stream
|
||||||
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
|
// read is the suffix for read stream
|
||||||
Read = "read"
|
read = "read"
|
||||||
// Starred is the suffix for starred stream
|
// starred is the suffix for starred stream
|
||||||
Starred = "starred"
|
starred = "starred"
|
||||||
// ReadingList is the suffix for reading list stream
|
// readingList is the suffix for reading list stream
|
||||||
ReadingList = "reading-list"
|
readingList = "reading-list"
|
||||||
// KeptUnread is the suffix for kept unread stream
|
// keptUnread is the suffix for kept unread stream
|
||||||
KeptUnread = "kept-unread"
|
keptUnread = "kept-unread"
|
||||||
// Broadcast is the suffix for broadcast stream
|
// broadcast is the suffix for broadcast stream
|
||||||
Broadcast = "broadcast"
|
broadcast = "broadcast"
|
||||||
// BroadcastFriends is the suffix for broadcast friends stream
|
// broadcastFriends is the suffix for broadcast friends stream
|
||||||
BroadcastFriends = "broadcast-friends"
|
broadcastFriends = "broadcast-friends"
|
||||||
// Like is the suffix for like stream
|
// like is the suffix for like stream
|
||||||
Like = "like"
|
like = "like"
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,28 +64,28 @@ func parseStreamFilterFromRequest(r *http.Request) (RequestModifiers, error) {
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|
||||||
streamOrder := request.QueryStringParam(r, ParamStreamOrder, "d")
|
streamOrder := request.QueryStringParam(r, paramStreamOrder, "d")
|
||||||
if streamOrder == "o" {
|
if streamOrder == "o" {
|
||||||
result.SortDirection = "asc"
|
result.SortDirection = "asc"
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
result.Streams, err = getStreams(request.QueryStringParamList(r, ParamStreamID), userID)
|
result.Streams, err = getStreams(request.QueryStringParamList(r, paramStreamID), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RequestModifiers{}, err
|
return RequestModifiers{}, err
|
||||||
}
|
}
|
||||||
result.ExcludeTargets, err = getStreams(request.QueryStringParamList(r, ParamStreamExcludes), userID)
|
result.ExcludeTargets, err = getStreams(request.QueryStringParamList(r, paramStreamExcludes), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RequestModifiers{}, err
|
return RequestModifiers{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result.FilterTargets, err = getStreams(request.QueryStringParamList(r, ParamStreamFilters), userID)
|
result.FilterTargets, err = getStreams(request.QueryStringParamList(r, paramStreamFilters), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RequestModifiers{}, err
|
return RequestModifiers{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Count = request.QueryIntParam(r, ParamStreamMaxItems, 0)
|
result.Count = request.QueryIntParam(r, paramStreamMaxItems, 0)
|
||||||
result.Offset = request.QueryIntParam(r, ParamContinuation, 0)
|
result.Offset = request.QueryIntParam(r, paramContinuation, 0)
|
||||||
result.StartTime = request.QueryInt64Param(r, ParamStreamStartTime, int64(0))
|
result.StartTime = request.QueryInt64Param(r, paramStreamStartTime, int64(0))
|
||||||
result.StopTime = request.QueryInt64Param(r, ParamStreamStopTime, int64(0))
|
result.StopTime = request.QueryInt64Param(r, paramStreamStopTime, int64(0))
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,32 +72,34 @@ func (st StreamType) String() string {
|
||||||
|
|
||||||
func getStream(streamID string, userID int64) (Stream, error) {
|
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)) || strings.HasPrefix(streamID, StreamPrefix):
|
case strings.HasPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID)),
|
||||||
id := strings.TrimPrefix(streamID, fmt.Sprintf(UserStreamPrefix, userID))
|
strings.HasPrefix(streamID, streamPrefix):
|
||||||
id = strings.TrimPrefix(id, StreamPrefix)
|
id := strings.TrimPrefix(streamID, fmt.Sprintf(userStreamPrefix, userID))
|
||||||
|
id = strings.TrimPrefix(id, streamPrefix)
|
||||||
switch id {
|
switch id {
|
||||||
case Read:
|
case read:
|
||||||
return Stream{ReadStream, ""}, nil
|
return Stream{ReadStream, ""}, nil
|
||||||
case Starred:
|
case starred:
|
||||||
return Stream{StarredStream, ""}, nil
|
return Stream{StarredStream, ""}, nil
|
||||||
case ReadingList:
|
case readingList:
|
||||||
return Stream{ReadingListStream, ""}, nil
|
return Stream{ReadingListStream, ""}, nil
|
||||||
case KeptUnread:
|
case keptUnread:
|
||||||
return Stream{KeptUnreadStream, ""}, nil
|
return Stream{KeptUnreadStream, ""}, nil
|
||||||
case Broadcast:
|
case broadcast:
|
||||||
return Stream{BroadcastStream, ""}, nil
|
return Stream{BroadcastStream, ""}, nil
|
||||||
case BroadcastFriends:
|
case broadcastFriends:
|
||||||
return Stream{BroadcastFriendsStream, ""}, nil
|
return Stream{BroadcastFriendsStream, ""}, nil
|
||||||
case Like:
|
case like:
|
||||||
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)) || strings.HasPrefix(streamID, LabelPrefix):
|
case strings.HasPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID)),
|
||||||
id := strings.TrimPrefix(streamID, fmt.Sprintf(UserLabelPrefix, userID))
|
strings.HasPrefix(streamID, labelPrefix):
|
||||||
id = strings.TrimPrefix(id, LabelPrefix)
|
id := strings.TrimPrefix(streamID, fmt.Sprintf(userLabelPrefix, userID))
|
||||||
|
id = strings.TrimPrefix(id, labelPrefix)
|
||||||
return Stream{LabelStream, id}, nil
|
return Stream{LabelStream, id}, nil
|
||||||
case streamID == "":
|
case streamID == "":
|
||||||
return Stream{NoStream, ""}, nil
|
return Stream{NoStream, ""}, nil
|
||||||
|
@ -107,7 +109,7 @@ func getStream(streamID string, userID int64) (Stream, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStreams(streamIDs []string, userID int64) ([]Stream, error) {
|
func getStreams(streamIDs []string, userID int64) ([]Stream, error) {
|
||||||
streams := make([]Stream, 0)
|
streams := make([]Stream, 0, len(streamIDs))
|
||||||
for _, streamID := range streamIDs {
|
for _, streamID := range streamIDs {
|
||||||
stream, err := getStream(streamID, userID)
|
stream, err := getStream(streamID, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue