Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/ninety-icons-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@audius/sdk": patch
---

Add 'fan' prefix to remix contest notifs
18 changes: 9 additions & 9 deletions packages/common/src/adapters/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,36 +643,36 @@ export const notificationFromSDK = (
...formatBaseNotification(notification)
}
}
case 'remix_contest_started': {
case 'fan_remix_contest_ended': {
const data = notification.actions[0].data
return {
type: NotificationType.RemixContestStarted,
type: NotificationType.FanRemixContestEnded,
entityId: HashId.parse(data.entityId),
entityUserId: HashId.parse(data.entityUserId),
...formatBaseNotification(notification)
}
}
case 'remix_contest_ended': {
case 'artist_remix_contest_ended': {
const data = notification.actions[0].data
return {
type: NotificationType.RemixContestEnded,
type: NotificationType.ArtistRemixContestEnded,
entityId: HashId.parse(data.entityId),
entityUserId: HashId.parse(data.entityUserId),
...formatBaseNotification(notification)
}
}
case 'artist_remix_contest_ended': {
case 'fan_remix_contest_ending_soon': {
const data = notification.actions[0].data
return {
type: NotificationType.ArtistRemixContestEnded,
type: NotificationType.FanRemixContestEndingSoon,
entityId: HashId.parse(data.entityId),
entityUserId: HashId.parse(data.entityUserId),
...formatBaseNotification(notification)
}
}
case 'remix_contest_ending_soon': {
case 'fan_remix_contest_started': {
const data = notification.actions[0].data
return {
type: NotificationType.RemixContestEndingSoon,
type: NotificationType.FanRemixContestStarted,
entityId: HashId.parse(data.entityId),
entityUserId: HashId.parse(data.entityUserId),
...formatBaseNotification(notification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const useNotificationValidTypes = () => {
ValidTypes.ClaimableReward,
ValidTypes.ListenStreakReminder,
ValidTypes.ArtistRemixContestEnded,
ValidTypes.RemixContestStarted,
ValidTypes.RemixContestEnded,
ValidTypes.RemixContestEndingSoon
ValidTypes.FanRemixContestStarted,
ValidTypes.FanRemixContestEnded,
ValidTypes.FanRemixContestEndingSoon
]
}
30 changes: 15 additions & 15 deletions packages/common/src/store/notifications/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export enum NotificationType {
Milestone = 'Milestone',
RemixCreate = 'RemixCreate',
RemixCosign = 'RemixCosign',
RemixContestStarted = 'RemixContestStarted',
RemixContestEnded = 'RemixContestEnded',
RemixContestEndingSoon = 'RemixContestEndingSoon',
FanRemixContestStarted = 'FanRemixContestStarted',
FanRemixContestEnded = 'FanRemixContestEnded',
FanRemixContestEndingSoon = 'FanRemixContestEndingSoon',
Tastemaker = 'Tastemaker',
TrendingTrack = 'TrendingTrack',
TrendingPlaylist = 'TrendingPlaylist',
Expand Down Expand Up @@ -699,27 +699,27 @@ export type ListenStreakReminderNotification = BaseNotification & {
streak: number
}

export type RemixContestStartedNotification = BaseNotification & {
type: NotificationType.RemixContestStarted
export type FanRemixContestStartedNotification = BaseNotification & {
type: NotificationType.FanRemixContestStarted
entityId: ID
entityUserId: ID
}

export type RemixContestEndedNotification = BaseNotification & {
type: NotificationType.RemixContestEnded
export type FanRemixContestEndingSoonNotification = BaseNotification & {
type: NotificationType.FanRemixContestEndingSoon
entityId: ID
entityUserId: ID
}

export type RemixContestEndingSoonNotification = BaseNotification & {
type: NotificationType.RemixContestEndingSoon
export type ArtistRemixContestEndedNotification = BaseNotification & {
type: NotificationType.ArtistRemixContestEnded
entityId: ID
entityUserId: ID
}

export type ArtistRemixContestEndedNotification = BaseNotification & {
type: NotificationType.ArtistRemixContestEnded
export type FanRemixContestEndedNotification = BaseNotification & {
type: NotificationType.FanRemixContestEnded
entityId: ID
entityUserId: ID
}

export type Notification =
Expand All @@ -733,9 +733,8 @@ export type Notification =
| MilestoneNotification
| RemixCreateNotification
| RemixCosignNotification
| RemixContestStartedNotification
| RemixContestEndedNotification
| RemixContestEndingSoonNotification
| FanRemixContestStartedNotification
| FanRemixContestEndingSoonNotification
| TastemakerNotification
| TrendingPlaylistNotification
| TrendingTrackNotification
Expand All @@ -761,6 +760,7 @@ export type Notification =
| CommentReactionNotification
| ListenStreakReminderNotification
| ArtistRemixContestEndedNotification
| FanRemixContestEndedNotification

export type IdentityNotification = Omit<Notification, 'timestamp'> & {
timestamp: string
Expand Down
4 changes: 2 additions & 2 deletions packages/discovery-provider/ddl/functions/handle_event.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ begin
new.blocknumber,
ARRAY[notified_user_id],
new.created_at,
'remix_contest_started',
'fan_remix_contest_started',
notified_user_id,
'remix_contest_started:' || new.entity_id || ':user:' || new.user_id || ':blocknumber:' || new.blocknumber,
'fan_remix_contest_started:' || new.entity_id || ':user:' || new.user_id || ':blocknumber:' || new.blocknumber,
json_build_object(
'entity_user_id', owner_user_id,
'entity_id', new.entity_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
TEST_REMIXER_ID_2 = 3


def test_remix_contest_ended_notification_for_remixers(app):
def test_fan_remix_contest_ended_notification_for_remixers(app):
"""Test that remix contest ended notification is created for all remixers of the contest track"""
with app.app_context():
db = get_db()
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_remix_contest_ended_notification_for_remixers(app):
create_fan_remix_contest_ended_notifications(session)
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_ENDED)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_ENDED)
.all()
)
notified_user_ids = set()
Expand All @@ -105,15 +105,15 @@ def test_remix_contest_ended_notification_for_remixers(app):
# entity_user_id should be the original artist
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_ENDED
assert notification.group_id.startswith("remix_contest_ended:")
assert notification.type == NotificationType.FAN_REMIX_CONTEST_ENDED
assert notification.group_id.startswith("fan_remix_contest_ended:")
# Should notify both remixers
assert TEST_REMIXER_ID_1 in notified_user_ids
assert TEST_REMIXER_ID_2 in notified_user_ids
assert len(notified_user_ids) == 2


def test_remix_contest_ended_notification_no_duplicate_for_multiple_remixes(app):
def test_fan_remix_contest_ended_notification_no_duplicate_for_multiple_remixes(app):
"""Test that a user who submitted multiple remixes only gets one notification"""
with app.app_context():
db = get_db()
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_remix_contest_ended_notification_no_duplicate_for_multiple_remixes(app)
create_fan_remix_contest_ended_notifications(session)
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_ENDED)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_ENDED)
.all()
)
notif_count = 0
Expand All @@ -195,6 +195,6 @@ def test_remix_contest_ended_notification_no_duplicate_for_multiple_remixes(app)
notif_count += 1
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_ENDED
assert notification.group_id.startswith("remix_contest_ended:")
assert notification.type == NotificationType.FAN_REMIX_CONTEST_ENDED
assert notification.group_id.startswith("fan_remix_contest_ended:")
assert notif_count == 1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
TEST_FAVORITER_ID = 3


def test_remix_contest_ending_soon_notification_for_followers_and_favoriters(app):
def test_fan_remix_contest_ending_soon_notification_for_followers_and_favoriters(app):
"""Test that remix contest ending soon notification is created for followers and users who favorited the track"""
with app.app_context():
db = get_db()
Expand Down Expand Up @@ -94,23 +94,23 @@ def test_remix_contest_ending_soon_notification_for_followers_and_favoriters(app
create_fan_remix_contest_ending_soon_notifications(session)
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_ENDING_SOON)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_ENDING_SOON)
.all()
)
notified_user_ids = set()
for notification in notifications:
notified_user_ids.update(notification.user_ids)
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_ENDING_SOON
assert notification.group_id.startswith("remix_contest_ending_soon:")
assert notification.type == NotificationType.FAN_REMIX_CONTEST_ENDING_SOON
assert notification.group_id.startswith("fan_remix_contest_ending_soon:")
# Should notify both the follower and the favoriter
assert TEST_FOLLOWER_ID in notified_user_ids
assert TEST_FAVORITER_ID in notified_user_ids
assert len(notified_user_ids) == 2


def test_remix_contest_ending_soon_notification_no_duplicate_for_follower_and_favoriter(
def test_fan_remix_contest_ending_soon_notification_no_duplicate_for_follower_and_favoriter(
app,
):
"""Test that a user who both follows the creator and saved the track only gets one notification"""
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_remix_contest_ending_soon_notification_no_duplicate_for_follower_and_fa
create_fan_remix_contest_ending_soon_notifications(session)
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_ENDING_SOON)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_ENDING_SOON)
.all()
)
notif_count = 0
Expand All @@ -193,6 +193,10 @@ def test_remix_contest_ending_soon_notification_no_duplicate_for_follower_and_fa
notif_count += 1
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_ENDING_SOON
assert notification.group_id.startswith("remix_contest_ending_soon:")
assert (
notification.type == NotificationType.FAN_REMIX_CONTEST_ENDING_SOON
)
assert notification.group_id.startswith(
"fan_remix_contest_ending_soon:"
)
assert notif_count == 1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
TEST_FAVORITER_ID = 3


def test_remix_contest_started_notification_for_followers_and_favoriters(app):
def test_fan_remix_contest_started_notification_for_followers_and_favoriters(app):
"""Test that remix contest started notification is created for followers and users who favorited the track"""
with app.app_context():
db = get_db()
Expand Down Expand Up @@ -95,23 +95,23 @@ def test_remix_contest_started_notification_for_followers_and_favoriters(app):
with db.scoped_session() as session:
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_STARTED)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_STARTED)
.all()
)
notified_user_ids = set()
for notification in notifications:
notified_user_ids.update(notification.user_ids)
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_STARTED
assert notification.group_id.startswith("remix_contest_started:")
assert notification.type == NotificationType.FAN_REMIX_CONTEST_STARTED
assert notification.group_id.startswith("fan_remix_contest_started:")
# Should notify both the follower and the favoriter
assert TEST_FOLLOWER_ID in notified_user_ids
assert TEST_FAVORITER_ID in notified_user_ids
assert len(notified_user_ids) == 2


def test_remix_contest_started_notification_no_duplicate_for_follower_and_favoriter(
def test_fan_remix_contest_started_notification_no_duplicate_for_follower_and_favoriter(
app,
):
"""Test that a user who both follows the creator and saved the track only gets one notification"""
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_remix_contest_started_notification_no_duplicate_for_follower_and_favori
with db.scoped_session() as session:
notifications = (
session.query(Notification)
.filter(Notification.type == NotificationType.REMIX_CONTEST_STARTED)
.filter(Notification.type == NotificationType.FAN_REMIX_CONTEST_STARTED)
.all()
)
# There should be only one notification for BOTH_ID
Expand All @@ -199,7 +199,7 @@ def test_remix_contest_started_notification_no_duplicate_for_follower_and_favori
notif_count += 1
assert notification.data["entity_user_id"] == TEST_EVENT_CREATOR_ID
assert notification.data["entity_id"] == TEST_TRACK_ID
assert notification.type == NotificationType.REMIX_CONTEST_STARTED
assert notification.type == NotificationType.FAN_REMIX_CONTEST_STARTED
assert notification.specifier == str(BOTH_ID)
assert notification.group_id.startswith("remix_contest_started:")
assert notification.group_id.startswith("fan_remix_contest_started:")
assert notif_count == 1
Loading