- $params = ['order' => ['relation-cid' => true], 'limit' => $request['limit']];
-
- $condition = ['cid' => $id, 'follows' => true];
-
- if (!empty($request['max_id'])) {
- $condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $request['max_id']]);
- }
-
- if (!empty($request['since_id'])) {
- $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['since_id']]);
- }
-
- if (!empty($request['min_id'])) {
- $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['min_id']]);
-
- $params['order'] = ['cid'];
- }
-
- $accounts = [];
-
- $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
- while ($follower = DBA::fetch($followers)) {
- self::setBoundaries($follower['relation-cid']);
- $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);
+ if (false && $id == Contact::getPublicIdByUserId($uid)) {
+ $params = ['order' => ['pid' => true], 'limit' => $request['limit']];
+
+ $condition = ['uid' => $uid, 'self' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
+
+ if (!empty($request['max_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`pid` < ?", $request['max_id']]);
+ }
+
+ if (!empty($request['since_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`pid` > ?", $request['since_id']]);
+ }
+
+ if (!empty($request['min_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`pid` > ?", $request['min_id']]);
+
+ $params['order'] = ['pid'];
+ }
+
+ $accounts = [];
+
+ foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) {
+ self::setBoundaries($follower['pid']);
+ $accounts[] = DI::mstdnAccount()->createFromContactId($follower['pid'], $uid);
+ }
+ } else {
+ $params = ['order' => ['relation-cid' => true], 'limit' => $request['limit']];
+
+ $condition = ['cid' => $id, 'follows' => true];
+
+ if (!empty($request['max_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $request['max_id']]);
+ }
+
+ if (!empty($request['since_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['since_id']]);
+ }
+
+ if (!empty($request['min_id'])) {
+ $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['min_id']]);
+
+ $params['order'] = ['relation-cid'];
+ }
+
+ $accounts = [];
+
+ $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $params);
+ while ($follower = DBA::fetch($followers)) {
+ self::setBoundaries($follower['relation-cid']);
+ $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);
+ }
+ DBA::close($followers);