Skip to content

Commit cd02c01

Browse files
committed
Merge branch 'master' into feature/ads-banner
2 parents a65953a + 0db8162 commit cd02c01

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/graphql/user.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export const typeDef = gql`
6464
acceptIntegration: String!
6565
initiateChangeEmail(email: String!): Boolean
6666
confirmChangeEmail(code: String!): Boolean
67-
follow(following_user_id: ID!, post_id: ID!): Post
68-
unfollow(following_user_id: ID!, post_id: ID!): Post
67+
follow(following_user_id: ID!): User
68+
unfollow(following_user_id: ID!): User
6969
}
7070
`;
7171

@@ -302,11 +302,11 @@ export const resolvers: IResolvers<any, ApolloContext> = {
302302
},
303303
follow: async (_, args: { following_user_id: string; post_id: string }, ctx) => {
304304
if (!ctx.user_id) throw new AuthenticationError('Not Logged In');
305-
return await userService.follow(args.following_user_id, args.post_id, ctx.cookies);
305+
return await userService.follow(args.following_user_id, ctx.cookies);
306306
},
307307
unfollow: async (_, args: { following_user_id: string; post_id: string }, ctx) => {
308308
if (!ctx.user_id) throw new AuthenticationError('Not Logged In');
309-
return await userService.unfollow(args.following_user_id, args.post_id, ctx.cookies);
309+
return await userService.unfollow(args.following_user_id, ctx.cookies);
310310
},
311311
},
312312
};

src/services/userService.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,8 @@ const userService = {
141141
cache.client?.del(key);
142142
return true;
143143
},
144-
async follow(followingUserId: string, postId: string, cookies: Cookies) {
144+
async follow(followingUserId: string, cookies: Cookies) {
145145
try {
146-
const post = await postService.findPostById(postId);
147-
148-
if (!post) {
149-
throw new ApolloError('Post not found', 'NOT_FOUND');
150-
}
151-
152146
const query = 'mutation Follow ($input: FollowInput!) {\n\tfollow(input: $input) \n}';
153147

154148
const accessToken = cookies.get('access_token') ?? '';
@@ -173,20 +167,14 @@ const userService = {
173167
}
174168
);
175169

176-
return { id: post.id };
170+
return { id: followingUserId, is_followed: true };
177171
} catch (error: any) {
178172
console.log('follow error:', error.response.data.errors);
179173
return false;
180174
}
181175
},
182-
async unfollow(followingUserId: string, postId: string, cookies: Cookies) {
176+
async unfollow(followingUserId: string, cookies: Cookies) {
183177
try {
184-
const post = await postService.findPostById(postId);
185-
186-
if (!post) {
187-
throw new ApolloError('Post not found', 'NOT_FOUND');
188-
}
189-
190178
const query = 'mutation Unfollow ($input: UnfollowInput!) {\n\tunfollow(input: $input) \n}';
191179

192180
const accessToken = cookies.get('access_token') ?? '';
@@ -211,7 +199,7 @@ const userService = {
211199
}
212200
);
213201

214-
return { id: post.id };
202+
return { id: followingUserId, is_followed: false };
215203
} catch (error: any) {
216204
console.log('unfollow error:', error.response.data.errors);
217205
return false;

0 commit comments

Comments
 (0)