🐛 Fix notify original poster wrongly
This commit is contained in:
		| @@ -505,21 +505,28 @@ func NotifyReplying(item models.Post, user models.Publisher) error { | |||||||
| 	content, ok := item.Body["content"].(string) | 	content, ok := item.Body["content"].(string) | ||||||
| 	if !ok { | 	if !ok { | ||||||
| 		content = "Posted a post" | 		content = "Posted a post" | ||||||
|  | 	} else { | ||||||
|  | 		content = TruncatePostContentShort(content) | ||||||
| 	} | 	} | ||||||
| 	var title *string |  | ||||||
| 	title, _ = item.Body["title"].(*string) | 	var op models.Post | ||||||
| 	item.Publisher = user | 	if err := database.C. | ||||||
| 	if err := NotifyUserSubscription(user, item, content, title); err != nil { | 		Where("id = ?", item.ReplyID). | ||||||
| 		log.Error().Err(err).Msg("An error occurred when notifying subscriptions user by user...") | 		Preload("Publisher"). | ||||||
| 	} | 		First(&op).Error; err == nil { | ||||||
| 	for _, tag := range item.Tags { | 		if op.Publisher.AccountID != nil && op.Publisher.ID != user.ID { | ||||||
| 		if err := NotifyTagSubscription(tag, user, item, content, title); err != nil { | 			log.Debug().Uint("user", *op.Publisher.AccountID).Msg("Notifying the original poster their post got replied...") | ||||||
| 			log.Error().Err(err).Msg("An error occurred when notifying subscriptions user by tag...") | 			err = NotifyPosterAccount( | ||||||
| 		} | 				op.Publisher, | ||||||
| 	} | 				op, | ||||||
| 	for _, category := range item.Categories { | 				"Post got replied", | ||||||
| 		if err := NotifyCategorySubscription(category, user, item, content, title); err != nil { | 				fmt.Sprintf("%s (%s) replied you: %s", user.Nick, user.Name, content), | ||||||
| 			log.Error().Err(err).Msg("An error occurred when notifying subscriptions user by category...") | 				"interactive.reply", | ||||||
|  | 				fmt.Sprintf("%s replied your post #%d", user.Nick, *item.ReplyID), | ||||||
|  | 			) | ||||||
|  | 			if err != nil { | ||||||
|  | 				log.Error().Err(err).Msg("An error occurred when notifying user...") | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user