Ejemplo n.º 1
0
func (s *ApiServer) MarkDelete(feedId string) (bool, error) {
	profile, err := store.GetProfile(s.mdb, feedId)
	if err != nil {
		return false, err
	}
	profile.Deleted = true
	store.UpdateProfile(s.mdb, profile)
	return true, nil
}
Ejemplo n.º 2
0
func (s *ApiServer) PostFeedinfo(ctx context.Context, in *pb.Feedinfo) (*pb.Profile, error) {
	profile := &pb.Profile{
		Uuid:        in.Uuid,
		Id:          in.Id,
		Name:        in.Name,
		Type:        in.Type,
		Private:     in.Private,
		SupId:       in.SupId,
		Description: in.Description,
	}
	// remote key only present when id == target_id
	if in.RemoteKey != "" {
		// record remote key
		profile.RemoteKey = in.RemoteKey
	}

	// profile.Picture = s.ArchiveProfilePicture(profile.Id)
	// log.Println("profile pic:", profile.Picture)

	if err := store.UpdateProfile(s.mdb, profile); err != nil {
		return nil, err
	}

	// save all feed info in one key for simplicity
	// TODO: refactor?
	in.Entries = []*pb.Entry{}
	if err := store.SaveFeedinfo(s.rdb, profile.Uuid, in); err != nil {
		return nil, err
	}

	// TODO: server overload, disable friends of feed
	// There is no way we can handle this much jobs in a short time.
	// remote key only present when id == target_id
	// if in.RemoteKey != "" {
	// 	for _, sub := range in.Subscriptions {
	// 		// enqueue user subscriptons
	// 		oldjob, err := store.GetArchiveHistory(s.mdb, sub.Id)
	// 		if err != nil || oldjob.Status == "done" {
	// 			// no aggressive archiving for friends of feed
	// 			log.Printf("%s previous archived.", sub.Id)
	// 			continue
	// 		}

	// 		ctx := context.Background()
	// 		key := store.NewFlakeKey(store.TableJobFeed, s.mdb.NextId())
	// 		job := &pb.FeedJob{
	// 			Key:       key.String(),
	// 			Id:        in.Id,
	// 			RemoteKey: in.RemoteKey,
	// 			TargetId:  sub.Id,
	// 			Start:     0,
	// 			PageSize:  100,
	// 			Created:   time.Now().Unix(),
	// 			Updated:   time.Now().Unix(),
	// 		}
	// 		s.EnqueJob(ctx, job)
	// 	}
	// }

	return profile, nil
}