func DeleteLike(rdb *Store, profile *pb.Profile, entry *pb.Entry) (*pb.Entry, error) { var err error index := -1 for i, like := range entry.Likes { if like.From.Id == profile.Id { index = i break } } if index >= 0 { entry.Likes = append(entry.Likes[:index], entry.Likes[index+1:]...) _, err = PutEntry(rdb, entry, true) } return entry, err }
func Like(rdb *Store, profile *pb.Profile, entry *pb.Entry) (*UUIDKey, *pb.Entry, error) { var err error var key *UUIDKey index := -1 for i, like := range entry.Likes { if like.From.Id == profile.Id { index = i break } } if index == -1 { like := &pb.Like{ Date: time.Now().Format(time.RFC3339), From: &pb.Feed{ Id: profile.Id, Name: profile.Name, Type: profile.Type, }, } entry.Likes = append(entry.Likes, like) key, err = PutEntry(rdb, entry, true) } return key, entry, err }