activityId is saved in db for streamable objects

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/374/head
Maxence Lange 2019-01-24 10:27:36 -01:00
rodzic accf7e424d
commit db55361148
3 zmienionych plików z 38 dodań i 2 usunięć

Wyświetl plik

@ -147,6 +147,17 @@ class CoreRequestBuilder {
}
/**
* Limit the request to the ActivityId
*
* @param IQueryBuilder $qb
* @param string $activityId
*/
protected function limitToActivityId(IQueryBuilder &$qb, string $activityId) {
$this->limitToDBField($qb, 'activity_id', $activityId, false);
}
/**
* Limit the request to the Preferred Username
*

Wyświetl plik

@ -157,6 +157,32 @@ class NotesRequest extends NotesRequestBuilder {
}
/**
* @param string $id
*
* @return Note
* @throws NoteNotFoundException
*/
public function getNoteByActivityId(string $id): Note {
if ($id === '') {
throw new NoteNotFoundException();
};
$qb = $this->getNotesSelectSql();
$this->limitToActivityId($qb, $id);
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor->closeCursor();
if ($data === false) {
throw new NoteNotFoundException('Post not found');
}
return $this->parseNotesSelectSql($data);
}
/**
* @param string $actorId
*

Wyświetl plik

@ -134,10 +134,9 @@ class NoteInterface implements IActivityPubInterface {
if ($activity->getType() === Create::TYPE) {
$activity->checkOrigin($item->getId());
$activity->checkOrigin($item->getAttributedTo());
$item->setActivityId($activity->getId());
$this->save($item);
}
}