/**
* Create a blurhash out of a given image string
*
- * @param string $img_str
* @return string
*/
- public function getBlurHash(): string
+ public function getBlurHash(string $img_str = ''): string
{
- $image = New Image($this->asString(), $this->getType(), $this->filename, false);
+ $image = new Image($img_str ?: $this->asString(), $this->getType(), $this->filename, false);
- if (empty($image) || !$this->isValid()) {
+ if (!$this->isValid()) {
return '';
}
return $contact;
}
- if (empty($contact)) {
- $fields = [
- 'uid' => $contact_uid,
- 'network' => Protocol::BLUESKY,
- 'priority' => 1,
- 'writable' => true,
- 'blocked' => false,
- 'readonly' => false,
- 'pending' => false,
- 'url' => $did,
- 'nurl' => $did,
- 'alias' => ATProtocol::WEB . '/profile/' . $did,
- 'name' => $did,
- 'nick' => $did,
- 'addr' => $did,
- 'rel' => Contact::NOTHING,
- ];
- $cid = Contact::insert($fields);
- } else {
- $cid = $contact['id'];
- }
+ $fields = [
+ 'uid' => $contact_uid,
+ 'network' => Protocol::BLUESKY,
+ 'priority' => 1,
+ 'writable' => true,
+ 'blocked' => false,
+ 'readonly' => false,
+ 'pending' => false,
+ 'url' => $did,
+ 'nurl' => $did,
+ 'alias' => ATProtocol::WEB . '/profile/' . $did,
+ 'name' => $did,
+ 'nick' => $did,
+ 'addr' => $did,
+ 'rel' => Contact::NOTHING,
+ ];
+
+ $cid = Contact::insert($fields);
- $this->updateContactByDID($did);
+ $this->updateContactByDID($did, $contact_uid);
return Contact::getById($cid);
}