// Unsubscribe removes a feed from the user's feed list. func unsubscribe(c appengine.Context, feedKey *datastore.Key) error { var f FeedInfo err := datastore.RunInTransaction(c, func(c appengine.Context) error { u, err := getUser(c) if err != nil { return err } i := 0 var k *datastore.Key for i, k = range u.Feeds { if feedKey.Equal(k) { break } } if i >= len(u.Feeds) { return nil } err = fixMissingFieldError(datastore.Get(c, feedKey, &f)) if err != nil { return err } f.Refs-- if f.Refs <= 0 { if err := f.rmArticles(c); err != nil { return err } if err := datastore.Delete(c, feedKey); err != nil { return err } memcache.Delete(c, articlesMcacheKey(feedKey)) } else if _, err := datastore.Put(c, feedKey, &f); err != nil { return err } u.Feeds = append(u.Feeds[:i], u.Feeds[i+1:]...) return putUser(c, &u) }, &datastore.TransactionOptions{XG: true}) if err != nil { return err } flushUserPageCache(c) if f.Refs <= 0 { memcache.Delete(c, mcacheFeedsKey) memcache.Delete(c, feedKey.StringID()) return nil } return memcache.Gob.Set(c, &memcache.Item{Key: feedKey.StringID(), Object: f}) }
// Unsubscribe removes a feed from the user's feed list. func unsubscribe(c appengine.Context, feedKey *datastore.Key) error { return datastore.RunInTransaction(c, func(c appengine.Context) error { u, err := getUserInfo(c) if err != nil { return err } i := 0 var k *datastore.Key for i, k = range u.Feeds { if feedKey.Equal(k) { break } } if i >= len(u.Feeds) { return nil } var f FeedInfo if err := datastore.Get(c, feedKey, &f); err != nil { return err } f.Refs-- if f.Refs <= 0 { if err := f.rmArticles(c); err != nil { return err } if err := datastore.Delete(c, feedKey); err != nil { return err } } else if _, err := datastore.Put(c, feedKey, &f); err != nil { return err } u.Feeds = append(u.Feeds[:i], u.Feeds[i+1:]...) _, err = datastore.Put(c, userInfoKey(c), &u) return err }, &datastore.TransactionOptions{XG: true}) }
func (cd ContextDefinition) IsUserOwner(userKey *datastore.Key) bool { return userKey.Equal(cd.Owner) }