Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b222132
fix(notifications): reply original tweet data
MoBahgat010 Dec 11, 2025
40f9ad3
fix(notifications): reply original tweet data
MoBahgat010 Dec 11, 2025
f7ffa24
fix(notifications): reply original tweet data
MoBahgat010 Dec 11, 2025
19b73f1
fix(notifications): reply original tweet data
MoBahgat010 Dec 11, 2025
272c85c
fix(notifications): reply original tweet data
MoBahgat010 Dec 11, 2025
27c8793
fix(notifications): extra data
MoBahgat010 Dec 12, 2025
a8d8ad4
fix(notifications): extra data
MoBahgat010 Dec 12, 2025
cce4999
fix(notifications): extra data
MoBahgat010 Dec 12, 2025
70e9138
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
a165af4
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
ce5b6a0
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
a53b1f3
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
8c2dcb0
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
98eb526
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
c20cd9c
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
52ef601
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
3672727
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
0b1b1c4
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
d7eb6ce
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
20ea714
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
e660cf2
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
3ae7816
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
08fc1fa
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
635cb5e
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
a250326
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
a2d949b
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
cdec037
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
2e194fc
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
bda268b
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
ef6ff1b
fix(notifications): push notification format
MoBahgat010 Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/expo/expo.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('FCMService', () => {
it('should send LIKE notification successfully', async () => {
const payload = {
likers: [{ name: 'John Doe' }],
tweets: [{ content: 'Tweet content' }],
tweets: [{ content: 'Tweet content', id: 'tweet-123' }],
tweet_id: 'tweet-123',
};

Expand All @@ -240,8 +240,7 @@ describe('FCMService', () => {
body: 'Tweet content',
subtitle: 'Tweet content',
data: {
type: NotificationType.LIKE,
...payload,
tweet_id: 'tweet-123',
},
},
]);
Expand All @@ -252,7 +251,7 @@ describe('FCMService', () => {
it('should send REPLY notification successfully', async () => {
const payload = {
replier: { name: 'Jane Smith' },
reply_tweet: { content: 'Reply content' },
reply_tweet: { content: 'Reply content', id: 'tweet-456' },
tweet_id: 'tweet-456',
};

Expand All @@ -277,7 +276,7 @@ describe('FCMService', () => {
it('should send REPOST notification successfully', async () => {
const payload = {
reposter: { name: 'Bob Johnson' },
tweet: { content: 'Tweet content' },
tweet: { content: 'Tweet content', id: 'tweet-789' },
};

await service.sendNotificationToUserDevice(
Expand All @@ -299,7 +298,7 @@ describe('FCMService', () => {
it('should send QUOTE notification successfully', async () => {
const payload = {
quoted_by: { username: 'alice' },
quote: { content: 'Quote content' },
quote: { content: 'Quote content', id: 'tweet-101' },
};

await service.sendNotificationToUserDevice('user-123', NotificationType.QUOTE, payload);
Expand All @@ -317,7 +316,7 @@ describe('FCMService', () => {
it('should send MENTION notification successfully', async () => {
const payload = {
mentioned_by: { name: 'Charlie Wilson' },
tweet: { content: 'Tweet content' },
tweet: { content: 'Tweet content', id: 'tweet-202' },
};

await service.sendNotificationToUserDevice(
Expand All @@ -339,7 +338,8 @@ describe('FCMService', () => {
it('should send MESSAGE notification successfully', async () => {
const payload = {
sender: { name: 'David Lee' },
message: { content: 'Hello!' },
content: 'Hello!',
chat_id: 'chat-123',
};

await service.sendNotificationToUserDevice(
Expand All @@ -361,6 +361,7 @@ describe('FCMService', () => {
it('should send FOLLOW notification with follower_name', async () => {
const payload = {
follower_username: 'emma',
follower_id: 'user-303',
};

await service.sendNotificationToUserDevice(
Expand Down Expand Up @@ -438,7 +439,7 @@ describe('FCMService', () => {

await service.sendNotificationToUserDevice('user-123', NotificationType.LIKE, {
likers: [{ name: 'Test' }],
tweets: [{ content: 'Content' }],
tweets: [{ content: 'Content', id: 'tweet-1' }],
});

expect(logger_spy).toHaveBeenCalledWith('Notification sent via FCM to user user-123');
Expand All @@ -456,7 +457,7 @@ describe('FCMService', () => {
NotificationType.LIKE,
{
likers: [{ name: 'Test' }],
tweets: [{ content: 'Content' }],
tweets: [{ content: 'Content', id: 'tweet-1' }],
}
);

Expand All @@ -475,7 +476,7 @@ describe('FCMService', () => {
username: 'complexuser',
},
],
tweets: [{ content: 'Tweet content' }],
tweets: [{ content: 'Tweet content', id: 'tweet-123' }],
tweet_id: 'tweet-123',
};

Expand All @@ -485,8 +486,7 @@ describe('FCMService', () => {
expect.arrayContaining([
expect.objectContaining({
data: {
type: NotificationType.LIKE,
...payload,
tweet_id: 'tweet-123',
},
}),
])
Expand Down
15 changes: 6 additions & 9 deletions src/expo/expo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ export class FCMService {
body: notification_content.body,
};

const data = {
type: notification_type,
...payload,
};

await this.sendToDevice(user.fcm_token, data, notification);
await this.sendToDevice(user.fcm_token, notification_content.data, notification);
this.logger.log(`Notification sent via FCM to user ${user_id}`);
return true;
} catch (error) {
Expand All @@ -127,13 +122,13 @@ export class FCMService {
private getNotificationContent(
type: NotificationType,
payload: any
): { title: string; body: string; data?: any } {
): { title: string; body: string; data: any } {
switch (type) {
case NotificationType.FOLLOW:
return {
title: 'yapper',
body: `@${payload.follower_username || 'Someone'} followed you!`,
data: { username: payload.follower_id },
data: { user_id: payload.follower_id },
};
case NotificationType.MENTION:
return {
Expand Down Expand Up @@ -183,12 +178,14 @@ export class FCMService {
case NotificationType.MESSAGE:
return {
title: payload.sender?.name || 'New Message',
body: payload.message?.content || 'You have a new message',
body: payload.content || 'You have a new message',
data: { chat_id: payload.chat_id },
};
default:
return {
title: 'yapper',
body: 'You have a new notification',
data: {},
};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/messages/messages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class MessagesService {
sender: {
name: sender.name,
username: sender.username,
chat_id,
},
}
);
Expand Down
3 changes: 1 addition & 2 deletions src/notifications/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ export class NotificationsService implements OnModuleInit {
old_notification: aggregation_result.old_notification,
});
} else {
console.log('Send in FCM');

console.log('Send Expo Push Notification');
await this.fcmService.sendNotificationToUserDevice(
user_id,
notification_data.type,
Expand Down