Skip to content

Commit 0bb5fbb

Browse files
Revert "fix: truncate X notification attachment titles to 140 characters" (#3800)
1 parent 4763491 commit 0bb5fbb

2 files changed

Lines changed: 1 addition & 64 deletions

File tree

__tests__/notifications/index.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,61 +1490,6 @@ describe('storeNotificationBundle', () => {
14901490
]);
14911491
});
14921492

1493-
it('should truncate attachment title for SocialTwitter posts exceeding 140 characters', () => {
1494-
const type = NotificationType.SourcePostAdded;
1495-
const longTitle = 'a'.repeat(200);
1496-
const post = {
1497-
...postsFixture[0],
1498-
title: longTitle,
1499-
type: PostType.SocialTwitter,
1500-
} as Reference<Post>;
1501-
const ctx: NotificationSourceContext & NotificationPostContext = {
1502-
userIds: [userId],
1503-
source: sourcesFixture[0] as Reference<Source>,
1504-
post,
1505-
};
1506-
const actual = generateNotificationV2(type, ctx);
1507-
1508-
expect(actual.attachments![0].title).toEqual(`${'a'.repeat(137)}...`);
1509-
expect(actual.attachments![0].title!.length).toEqual(140);
1510-
});
1511-
1512-
it('should not truncate attachment title for SocialTwitter posts within 140 characters', () => {
1513-
const type = NotificationType.SourcePostAdded;
1514-
const shortTitle = 'a'.repeat(140);
1515-
const post = {
1516-
...postsFixture[0],
1517-
title: shortTitle,
1518-
type: PostType.SocialTwitter,
1519-
} as Reference<Post>;
1520-
const ctx: NotificationSourceContext & NotificationPostContext = {
1521-
userIds: [userId],
1522-
source: sourcesFixture[0] as Reference<Source>,
1523-
post,
1524-
};
1525-
const actual = generateNotificationV2(type, ctx);
1526-
1527-
expect(actual.attachments![0].title).toEqual(shortTitle);
1528-
});
1529-
1530-
it('should not truncate attachment title for non-SocialTwitter posts', () => {
1531-
const type = NotificationType.SourcePostAdded;
1532-
const longTitle = 'a'.repeat(200);
1533-
const post = {
1534-
...postsFixture[0],
1535-
title: longTitle,
1536-
type: PostType.Article,
1537-
} as Reference<Post>;
1538-
const ctx: NotificationSourceContext & NotificationPostContext = {
1539-
userIds: [userId],
1540-
source: sourcesFixture[0] as Reference<Source>,
1541-
post,
1542-
};
1543-
const actual = generateNotificationV2(type, ctx);
1544-
1545-
expect(actual.attachments![0].title).toEqual(longTitle);
1546-
});
1547-
15481493
it('should generate user_post_added notification', () => {
15491494
const type = NotificationType.UserPostAdded;
15501495
const ctx: NotificationUserContext & NotificationPostContext = {

src/notifications/builder.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,10 @@ export class NotificationBuilder {
311311
post.type as keyof typeof postTypeToAttachmentType
312312
] ?? NotificationAttachmentType.Post;
313313

314-
const MAX_TWITTER_TITLE_LENGTH = 140;
315-
const title = post.title ?? '';
316-
const truncatedTitle =
317-
post.type === PostType.SocialTwitter &&
318-
title.length > MAX_TWITTER_TITLE_LENGTH
319-
? `${title.substring(0, MAX_TWITTER_TITLE_LENGTH - 3)}...`
320-
: title;
321-
322314
this.attachments.push({
323315
type,
324316
image: (post as ArticlePost)?.image || pickImageUrl(post),
325-
title: truncatedTitle,
317+
title: post.title ?? '',
326318
referenceId: post.id,
327319
});
328320
return this;

0 commit comments

Comments
 (0)