Skip to content

Commit 5d5e418

Browse files
committed
remove Dependency injection and functionality for DeleteLastNotificationTime
1 parent ccfd7ab commit 5d5e418

File tree

5 files changed

+7
-43
lines changed

5 files changed

+7
-43
lines changed

server/cmd/museum/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ func main() {
208208
stripeClients := billing.GetStripeClients()
209209
commonBillController := commonbilling.NewController(emailNotificationCtrl, storagBonusRepo, userRepo, usageRepo, billingRepo)
210210
appStoreController := controller.NewAppStoreController(defaultPlan,
211-
billingRepo, fileRepo, userRepo, commonBillController, notificationHistoryRepo)
211+
billingRepo, fileRepo, userRepo, commonBillController)
212212
remoteStoreController := &remoteStoreCtrl.Controller{Repo: remoteStoreRepository}
213213
playStoreController := controller.NewPlayStoreController(defaultPlan,
214-
billingRepo, fileRepo, userRepo, storagBonusRepo, commonBillController, notificationHistoryRepo)
214+
billingRepo, fileRepo, userRepo, storagBonusRepo, commonBillController)
215215
stripeController := controller.NewStripeController(plans, stripeClients,
216-
billingRepo, fileRepo, userRepo, storagBonusRepo, discordController, emailNotificationCtrl, offerController, commonBillController, notificationHistoryRepo)
216+
billingRepo, fileRepo, userRepo, storagBonusRepo, discordController, emailNotificationCtrl, offerController, commonBillController)
217217
billingController := controller.NewBillingController(plans,
218218
appStoreController, playStoreController, stripeController,
219219
discordController, emailNotificationCtrl,

server/pkg/controller/appstore.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type AppStoreController struct {
2929
UserRepo *repo.UserRepository
3030
BillingPlansPerCountry ente.BillingPlansPerCountry
3131
CommonBillCtrl *commonbilling.Controller
32-
NotificationCtrl *repo.NotificationHistoryRepository
3332
// appStoreSharedPassword is the password to be used to access AppStore APIs
3433
appStoreSharedPassword string
3534
}
@@ -41,7 +40,6 @@ func NewAppStoreController(
4140
fileRepo *repo.FileRepository,
4241
userRepo *repo.UserRepository,
4342
commonBillCtrl *commonbilling.Controller,
44-
notificationCtrl *repo.NotificationHistoryRepository,
4543
) *AppStoreController {
4644
appleSharedSecret := viper.GetString("apple.shared-secret")
4745
return &AppStoreController{
@@ -52,7 +50,6 @@ func NewAppStoreController(
5250
BillingPlansPerCountry: plans,
5351
appStoreSharedPassword: appleSharedSecret,
5452
CommonBillCtrl: commonBillCtrl,
55-
NotificationCtrl: notificationCtrl,
5653
}
5754
}
5855

@@ -121,10 +118,6 @@ func (c *AppStoreController) HandleNotification(ctx *gin.Context, notification a
121118
if err != nil {
122119
return stacktrace.Propagate(err, "")
123120
}
124-
err = c.NotificationCtrl.DeleteLastNotificationTime(subscription.UserID, "90_percent_consumed")
125-
if err != nil {
126-
return stacktrace.Propagate(err, "")
127-
}
128121

129122
} else {
130123
if notification.NotificationType == appstore.NotificationTypeDidChangeRenewalStatus {

server/pkg/controller/billing.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type BillingController struct {
3939
DiscordController *discord.DiscordController
4040
EmailNotificationCtrl *email.EmailNotificationController
4141
CommonBillCtrl *commonbilling.Controller
42-
NotificationHistory *repo.NotificationHistoryRepository
4342
}
4443

4544
// Return a new instance of BillingController
@@ -55,7 +54,7 @@ func NewBillingController(
5554
usageRepo *repo.UsageRepository,
5655
storageBonusRepo *storagebonus.Repository,
5756
commonBillCtrl *commonbilling.Controller,
58-
notificationHistory *repo.NotificationHistoryRepository,
57+
notificationHistoryRepo *repo.NotificationHistoryRepository,
5958
) *BillingController {
6059
return &BillingController{
6160
BillingPlansPerAccount: plans,
@@ -69,7 +68,6 @@ func NewBillingController(
6968
EmailNotificationCtrl: emailNotificationCtrl,
7069
StorageBonusRepo: storageBonusRepo,
7170
CommonBillCtrl: commonBillCtrl,
72-
NotificationHistory: notificationHistory,
7371
}
7472
}
7573

@@ -296,10 +294,7 @@ func (c *BillingController) VerifySubscription(
296294
if err != nil {
297295
return ente.Subscription{}, stacktrace.Propagate(err, "")
298296
}
299-
err = c.NotificationHistory.DeleteLastNotificationTime(currentSubscription.UserID, "90_percent_consumed")
300-
if err != nil {
301-
return ente.Subscription{}, stacktrace.Propagate(err, "")
302-
}
297+
303298
log.Info("Replaced subscription")
304299
newSubscription.ID = currentSubscription.ID
305300
if paymentProvider == ente.PlayStore &&
@@ -374,13 +369,6 @@ func (c *BillingController) UpdateSubscription(r ente.UpdateSubscriptionRequest)
374369
if err != nil {
375370
return stacktrace.Propagate(err, "")
376371
}
377-
378-
// Delete users entry from notification_history table on subscription update
379-
err = c.NotificationHistory.DeleteLastNotificationTime(r.UserID, "90_percent_consumed")
380-
if err != nil {
381-
return stacktrace.Propagate(err, "")
382-
}
383-
384372
err = c.BillingRepo.LogAdminTriggeredSubscriptionUpdate(r)
385373
return stacktrace.Propagate(err, "")
386374
}

server/pkg/controller/playstore.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type PlayStoreController struct {
2929
StorageBonusRepo *storagebonus.Repository
3030
BillingPlansPerCountry ente.BillingPlansPerCountry
3131
CommonBillCtrl *commonbilling.Controller
32-
NotificationCtrl *repo.NotificationHistoryRepository
3332
}
3433

3534
// PlayStorePackageName is the package name of the PlayStore item
@@ -43,7 +42,6 @@ func NewPlayStoreController(
4342
userRepo *repo.UserRepository,
4443
storageBonusRepo *storagebonus.Repository,
4544
commonBillCtrl *commonbilling.Controller,
46-
notificationCtrl *repo.NotificationHistoryRepository,
4745
) *PlayStoreController {
4846
playStoreClient, err := newPlayStoreClient()
4947
if err != nil {
@@ -61,7 +59,6 @@ func NewPlayStoreController(
6159
BillingPlansPerCountry: plans,
6260
StorageBonusRepo: storageBonusRepo,
6361
CommonBillCtrl: commonBillCtrl,
64-
NotificationCtrl: notificationCtrl,
6562
}
6663
}
6764

@@ -187,10 +184,6 @@ func (c *PlayStoreController) HandleNotification(notification playstore.Develope
187184
if err != nil {
188185
return stacktrace.Propagate(err, "")
189186
}
190-
err = c.NotificationCtrl.DeleteLastNotificationTime(subscription.UserID, "90_percent_consumed")
191-
if err != nil {
192-
return stacktrace.Propagate(err, "")
193-
}
194187
err = c.AcknowledgeSubscription(productID, transactionID)
195188
if err != nil {
196189
return stacktrace.Propagate(err, "")

server/pkg/controller/stripe.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type StripeController struct {
4141
EmailNotificationCtrl *emailCtrl.EmailNotificationController
4242
OfferController *offer.OfferController
4343
CommonBillCtrl *commonbilling.Controller
44-
NotificationCtrl *repo.NotificationHistoryRepository
4544
}
4645

4746
const BufferPeriodOnPaymentFailureInDays = 7
@@ -58,7 +57,6 @@ func NewStripeController(
5857
emailNotificationController *emailCtrl.EmailNotificationController,
5958
offerController *offer.OfferController,
6059
commonBillCtrl *commonbilling.Controller,
61-
notificationCtrl *repo.NotificationHistoryRepository,
6260
) *StripeController {
6361
return &StripeController{
6462
StripeClients: stripeClients,
@@ -71,7 +69,6 @@ func NewStripeController(
7169
EmailNotificationCtrl: emailNotificationController,
7270
OfferController: offerController,
7371
CommonBillCtrl: commonBillCtrl,
74-
NotificationCtrl: notificationCtrl,
7572
}
7673
}
7774

@@ -265,12 +262,8 @@ func (c *StripeController) handleCheckoutSessionCompleted(event stripe.Event, co
265262
if err != nil {
266263
return ente.StripeEventLog{UserID: userID, StripeSubscription: stripeSubscription, Event: event}, stacktrace.Propagate(err, "Failed to change subscription")
267264
}
268-
265+
269266
// Execute DeleteLastNotificationTime entry after successful execution of ReplaceSubscription
270-
err = c.NotificationCtrl.DeleteLastNotificationTime(newSubscription.UserID, "90_percent_consumed")
271-
if err != nil {
272-
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
273-
}
274267
return ente.StripeEventLog{UserID: userID, StripeSubscription: stripeSubscription, Event: event}, nil
275268
} else {
276269
priceID, err := c.getPriceIDFromSession(session.ID)
@@ -313,10 +306,7 @@ func (c *StripeController) handleCustomerSubscriptionUpdated(event stripe.Event,
313306
// events to update the state
314307
if currentSubscription.ProductID != newSubscription.ProductID {
315308
c.BillingRepo.ReplaceSubscription(currentSubscription.ID, newSubscription)
316-
err := c.NotificationCtrl.DeleteLastNotificationTime(currentSubscription.UserID, "90_percent_consumed")
317-
if err != nil {
318-
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
319-
}
309+
320310
}
321311

322312
fullStripeSub, err := c.getStripeSubscriptionWithPaymentMethod(currentSubscription)

0 commit comments

Comments
 (0)