it's look like already have well design in src/Model/Contact; i can just use it on API.
goal setting: can follow by url (mastodon / diaspora* / friendica) or existing contact id or email
function api_friendships_destroy($type)
{
$cid = $_REQUEST['cid'];
$result = Contact::remove($cid);
return api_format_data('results', $type, ['results' => $result]);
}
function api_friendships_create($type)
{
$url = $_REQUEST['url'];
// here will do the magic, create remote user to local network (testing on diaspora* / mastodon is works)
$uid = Contact::getIdForURL($url);
// when user is Friendica user, will cause error, still need to find the correct way
$result = Contact::createFromProbe(api_user(), $url, true);
return api_format_data("results", $type, ['results' => $result]);
}
function api_friendships_exists($type)
{
// need more research on where the code i can reuse
}
it's look like already have well design in src/Model/Contact; i can just use it on API. goal setting: can follow by url (mastodon / diaspora* / friendica) or existing contact id or email
testing URL: https://jason.holi.chat/api/friendships/create?url=jasoncheng@diasp.org https://jason.holi.chat/api/friendships/destroy?cid=547