Skip to content

Commit

Permalink
[Add] 리졸버에서 자기자신과 자기 친구들만 새글 알림을 받도록 함 #140
Browse files Browse the repository at this point in the history
새글이 피드에 등록되어야 하고 새 피드가 알람이 와야함.
새 글 알림을 payload로 전달받은 등록자와 subscribe 에 등록된 사용자의 email을 비교해서 알림 발송
  • Loading branch information
WooYeonSeo committed Dec 5, 2019
1 parent a30b038 commit 11cd92d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/src/composition/Feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const FeedList = () => {
const { data: myInfo } = useMeQuery();
const { data, fetchMore, subscribeToMore } = useGetfeedsQuery({
variables: { first: OFFSET, currentCursor: '9999-12-31T09:29:26.050Z' },
notifyOnNetworkStatusChange: true
fetchPolicy: 'network-only'
});

const scrollTop = () => {
Expand Down
16 changes: 5 additions & 11 deletions server/src/api/feed/feed.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const checkIsFriend = async (friendEmail, myEmail) => {
});
const [parsedResult] = ParseResultRecords(result.records);

console.log('parsedResult ', parsedResult);
if (parsedResult.isFriend > 0) {
return true;
}
Expand Down Expand Up @@ -174,23 +173,18 @@ export default {
feeds: {
subscribe: withFilter(
(_, __, { pubsub }) => {
console.log('subscribed');
return pubsub.asyncIterator(NEW_FEED);
},
async (_, variables, context) => {
async (payload, _, context) => {
const myEmail = context.email;
const friendEmail = variables.userEmail;
const friendEmail = payload.feeds.feedItems[0].searchUser.email;
const isFriend = await checkIsFriend(friendEmail, myEmail);
/* if (isFriend && myEmail === friendEmail) {

if (isFriend || myEmail === friendEmail) {
return true;
} else {
return false;
} */

console.log(isFriend);
console.log('myEmail ', myEmail);
console.log('friendEmail ', friendEmail);
return true;
}
}
)
}
Expand Down

0 comments on commit 11cd92d

Please sign in to comment.