Issue 11831: Activate "notify on new post" via API

This commit is contained in:
Michael 2022-11-06 06:11:22 +00:00
parent b9f0985467
commit bc7d21183d

View file

@ -40,6 +40,10 @@ class Follow extends BaseApi
DI::mstdnError()->UnprocessableEntity(); DI::mstdnError()->UnprocessableEntity();
} }
$request = $this->getRequest([
'notify' => false, // Notify on new posts.
], $request);
$contact = Contact::getById($this->parameters['id'], ['url']); $contact = Contact::getById($this->parameters['id'], ['url']);
$result = Contact::createFromProbeForUser($uid, $contact['url']); $result = Contact::createFromProbeForUser($uid, $contact['url']);
@ -48,6 +52,8 @@ class Follow extends BaseApi
DI::mstdnError()->UnprocessableEntity($result['message']); DI::mstdnError()->UnprocessableEntity($result['message']);
} }
Contact::update(['notify_new_posts' => $request['notify']], ['id' => $result['cid']]);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($result['cid'], $uid)->toArray()); System::jsonExit(DI::mstdnRelationship()->createFromContactId($result['cid'], $uid)->toArray());
} }
} }