Skip to content

Commit

Permalink
feat(api): make getUnfollowers request work without twitter api
Browse files Browse the repository at this point in the history
  • Loading branch information
PLhery committed Jun 23, 2023
1 parent 212a63f commit 45fbb4d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions unfollow-ninja-server/src/api/user.ts
Expand Up @@ -8,6 +8,7 @@ import { IUnfollowerEvent, WebEvent } from '../dao/userEventDao';
import { SUPPORTED_LANGUAGES_CONST } from '../utils/utils';
import { generateProCheckoutUrl, getManageSubscriptionUrl } from './stripe';
import moment from 'moment-timezone';
import { captureException } from '@sentry/node';

export function createUserRouter(dao: Dao) {
return (
Expand Down Expand Up @@ -185,10 +186,16 @@ export function createUserRouter(dao: Dao) {
).slice(0, 100);
if (unfollowers.length) {
const twitterApi = await dao.getUserDao(session.userId).getTwitterApi();
const results = await twitterApi.v2.users(
unfollowers.map((follower) => follower.followerId),
{ 'user.fields': 'profile_image_url' }
);
const results = await twitterApi.v2
.users(
unfollowers.map((follower) => follower.followerId),
{ 'user.fields': 'profile_image_url' }
)
.catch((err) => {
console.error(err);
captureException(err);
return { data: [] };
});
results.data?.forEach((user) => {
const unfollower = unfollowers.find((u) => u.followerId === user.id);
if (unfollower) {
Expand Down

0 comments on commit 45fbb4d

Please sign in to comment.