Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow / unfollow #117

Open
jasoncheng opened this issue Dec 24, 2018 · 2 comments
Open

follow / unfollow #117

jasoncheng opened this issue Dec 24, 2018 · 2 comments
Labels

Comments

@jasoncheng
Copy link
Owner

jasoncheng commented Dec 24, 2018

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
}

api_register_func('api/friendships/destroy', 'api_friendships_destroy', true, API_METHOD_DELETE);
api_register_func('api/friendships/create', 'api_friendships_create', true, API_METHOD_POST);
api_register_func('api/friendships/exists', 'api_friendships_exists', true, API_METHOD_GET);

testing URL:
https://jason.holi.chat/api/friendships/[email protected]
https://jason.holi.chat/api/friendships/destroy?cid=547

@jasoncheng
Copy link
Owner Author

not that simple, too complicate for me, temporary pause

@Rik44444
Copy link

great, yeah this would be a useful addition Jason, to be able to follow/be-friends with people via the app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants