From a3e75a0755582297d19cbe5e1b04953400c1fe24 Mon Sep 17 00:00:00 2001
From: Tagadda <36127788+Tagadda@users.noreply.github.com>
Date: Sat, 9 Jun 2018 11:04:50 +0200
Subject: [PATCH] Use id instead of acct

---
 bot.js   | 10 ++++------
 index.js |  3 ++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/bot.js b/bot.js
index f468d00..2642374 100644
--- a/bot.js
+++ b/bot.js
@@ -1,7 +1,7 @@
 const EventEmitter = require('events');
 const MastodonAPI = require('mastodon-api');
 
-// Todo: Implements block_user and block_domain
+// Todo: Implements mute_user and block_domain
 // Todo: Implements unfollow
 
 class Bot extends EventEmitter {
@@ -105,12 +105,10 @@ class Bot extends EventEmitter {
 
     /**
      * Follow a user
-     * @param {string} acct
+     * @param {int} id
      */
-    follow(acct) {
-        this.M.post('follows', {
-            uri: acct
-        });
+    follow(id) {
+        this.M.post('accounts/' + id + '/follow');
     }
 }
 
diff --git a/index.js b/index.js
index 08d72dc..f0b178d 100644
--- a/index.js
+++ b/index.js
@@ -17,6 +17,7 @@ client.start().then(() => {
 
 client.on('update', (msg) => {
     const acct = msg.account.acct;
+    const id = parseInt(msg.account.id);
     const acct_parts = acct.split('@');
 
     if (acct_parts.length === 1) {
@@ -35,7 +36,7 @@ client.on('update', (msg) => {
     //Todo: Implement #nobot detection
 
     following.push(acct);
-    client.follow(acct);
+    client.follow(id);
     console.log("NOW FOLLOWS: " + acct);
 });
 
-- 
GitLab