Vote for an image, 'up' or 'down' vote. Send 'veto' to undo a vote.

@param string $imageOrAlbumId
@param string $vote           (up | down | veto)

@see https://api.imgur.com/endpoints/gallery#gallery-voting

@return bool
501640
public function vote($imageOrAlbumId, $vote)
    {
        $this->validateVoteArgument($vote, ['up', 'down', 'veto']);

        return $this->post('gallery/' . $imageOrAlbumId . '/vote/' . $vote);
    }
964389
public function deletePoll(Poll $poll): bool
    {
        if (empty($poll->getAdminKey())) {
            throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
        }
        return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '?adminKey=' . $poll->getAdminKey());
    }
437659
public synchronized void storeVote(MemberId vote) {
    log.trace("Store vote {}", vote);
    metadataBuffer.writeString(8, vote != null ? vote.id() : null).flush();
  }
282393
def update_image_popularity_score(image_to_update = :all)

      def get_score_write_to_db(image)
        popularity_score = calculate_popularity(image)
        image.update_attribute(:popular_score, popularity_score)
      end

      if image_to_update == :all
        images = Lentil::Image.find(image_to_update)
        images.each  do |image|
          get_score_write_to_db(image)
        end
      elsif image_to_update.kind_of?(Integer)
          image = Lentil::Image.find(image_to_update)
          get_score_write_to_db(image)
      end
    end
905316
def up_vote!(voteable)
      begin
        up_vote(voteable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
770991
public function execute($image)
    {
        $mode = $this->argument(0)->type('bool')->value(true);

        imageinterlace($image->getCore(), $mode);

        return true;
    }
252945
public function submitToGallery($imageOrAlbumId, $data)
    {
        if (!isset($data['title'])) {
            throw new MissingArgumentException('title');
        }

        return $this->post('gallery/' . $imageOrAlbumId, $data);
    }
558764
public function postVote()
    {
        $vote = new Vote($this->di->get("db"));

        $user = $this->di->get("session")->get("user");

        $parentType = isset($_POST["parentType"]) ? $_POST["parentType"] : "";
        $downVote   = isset($_POST["downVote"])   ? $_POST["downVote"]   : null;
        $parentId   = isset($_POST["parentId"])   ? $_POST["parentId"]   : "";
        $upVote     = isset($_POST["upVote"])     ? $_POST["upVote"]     : null;

        if ($upVote != null) {
            return $vote->like($user, $parentId, $parentType);
        }
        if ($downVote != null) {
            return $vote->dislike($user, $parentId, $parentType);
        }
        return false;
    }
822534
public function vote(DataObject $post, $dir = 1) {
		$member = $this->securityContext->getMember();
		
		if ($this->requireVoteBalance && $member->VotesToGive <= 0) {
			$post->RemainingVotes = 0;
			return $post;
		}

		// we allow multiple votes - as many as the user has to give! unless
		// configured not to...
		$currentVote = null; 
		
		if ($this->singleVotes) {
			$votes = $post->currentVotesByUser();
			if (count($votes)) {
				$currentVote = $votes[0];
			}
		}
		
		if (!$currentVote) {
			$currentVote = MicroPostVote::create();
			$currentVote->UserID = $member->ID;
			$currentVote->PostID = $post->ID;
		}
		
		$currentVote->Direction = $dir > 0 ? 1 : -1;
		$currentVote->write();
		
		$list = DataList::create('MicroPostVote');
		
		$upList = $list->filter(array('PostID' => $post->ID, 'Direction' => 1));
		$post->Up = $upList->count();
		
		$downList = $list->filter(array('PostID' => $post->ID, 'Direction' => -1));
		$post->Down = $downList->count();
		
		$owner = $post->Owner();
		if (!$post->OwnerID || !$owner || !$owner->exists()) {
			$owner = Security::findAnAdministrator();
		}

		// write the post as the owner, and calculate some changes for the author
		$this->transactionManager->run(function () use ($post, $currentVote, $member) {
			$author = $post->Owner();
			if ($author && $author->exists() && $author->ID != $member->ID) {
				if ($currentVote->Direction > 0) {
					$author->Up += 1;
				} else {
					$author->Down += 1;
				}
				$author->write();
			}
			$post->write();
		}, $owner);

		$this->rewardMember($member, -1);
		$post->RemainingVotes = $member->VotesToGive;

		return $post;
	}
1100069
public function voteMinus($comment_id)
    {
        $this->checkId($comment_id);

        return $this->vote($comment_id, self::VOTE_MINUS);
    }
662578
def upvote(self):
        
        data = self.get_selected_item()
        if 'likes' not in data:
            self.term.flash()
        elif getattr(data['object'], 'archived'):
            self.term.show_notification("Voting disabled for archived post", style='Error')
        elif data['likes']:
            with self.term.loader('Clearing vote'):
                data['object'].clear_vote()
            if not self.term.loader.exception:
                data['likes'] = None
        else:
            with self.term.loader('Voting'):
                data['object'].upvote()
            if not self.term.loader.exception:
                data['likes'] = True
1016906
public function prepareModifyVote (Vote $existVote) : void
    {
        try {
            $this->prepareVoteInput($existVote);
            $this->setStateToVote();

            if ($this->_Votes->isUsingHandler()) : 
                $this->_Votes[$this->getVoteKey($existVote)] = $existVote;
            endif;
        }
        catch (\Exception $e) {
            throw $e;
        }
    }
449861
public function runOverlay(Image $image, $width, $color)
    {
        return $image->rectangle(
            $width / 2,
            $width / 2,
            $image->width() - ($width / 2),
            $image->height() - ($width / 2),
            function ($draw) use ($width, $color) {
                $draw->border($width, $color);
            }
        );
    }
370870
public function vote(TokenInterface $token, $object, array $attributes)
    {
        $result = VoterInterface::ACCESS_ABSTAIN;
        if (!$object instanceof FamilyInterface) {
            return $result;
        }
        if (VoterInterface::ACCESS_DENIED === $this->roleHierarchyVoter->vote($token, null, ['ROLE_DATA_MANAGER'])) {
            return VoterInterface::ACCESS_DENIED;
        }
        if (VoterInterface::ACCESS_GRANTED === $this->roleHierarchyVoter->vote($token, null, ['ROLE_DATA_ADMIN'])) {
            return VoterInterface::ACCESS_GRANTED;
        }
        $permissions = $this->extractPermissions($token);

        $result = VoterInterface::ACCESS_DENIED;
        foreach ($attributes as $attribute) {
            if (!$this->supportsAttribute($attribute)) {
                continue;
            }

            foreach ($permissions as $permission) {
                if ($permission->hasPermission($attribute) &&
                    $permission->getFamilyCode() === $object->getCode()
                ) {
                    return VoterInterface::ACCESS_GRANTED;
                }
            }
        }

        return $result;
    }
1296829
def up_voted?(votable)
      is_votable?(votable)
      vote = get_vote(votable)
      return false if vote.nil?
      return true if vote.has_attribute?(:up_vote) && vote.up_vote
      false
    end
533507
def vote(self, identifier, weight=100.0):
        ''' 
        '''
        for num_of_retries in range(default.max_retry):
            try:
                self.steem_instance().vote(identifier, 
                    weight, self.mainaccount)
                self.msg.message("voted for " + identifier)
                time.sleep(5)
            except Exception as e:
                if re.search(r'You have already voted in a similar way', str(e)):
                    self.msg.error_message('''Already voted on 
                                        {}'''.format(identifier))
                    return "already voted"
                else:
                    self.util.retry('''COULD NOT VOTE ON 
                                    {}'''.format(identifier), 
                                    e, num_of_retries, default.wait_time)
                    self.s = None
            else:
                return True
968337
func (shard *ringShard) Vote(up bool) bool {
	if up {
		changed := shard.IsDown()
		atomic.StoreInt32(&shard.down, 0)
		return changed
	}

	if shard.IsDown() {
		return false
	}

	atomic.AddInt32(&shard.down, 1)
	return shard.IsDown()
}