From e04b187702acb0c9908237a35b3a9857e2167b3f Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 4 Oct 2021 15:24:19 +0200 Subject: Refactor/tidy (#261) * tidy up streaming * cut down code duplication * test get followers/following * test streaming processor * fix some test models * add TimeMustParse * fix uri / url typo * make trace logging less verbose * make logging more consistent * disable quote on logging * remove context.Background * remove many extraneous mastodon references * regenerate swagger * don't log query on no rows result * log latency first for easier reading --- internal/processing/fromcommon.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'internal/processing/fromcommon.go') diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go index e14c36fd4..88f9994d4 100644 --- a/internal/processing/fromcommon.go +++ b/internal/processing/fromcommon.go @@ -96,12 +96,12 @@ func (p *processor) notifyStatus(ctx context.Context, status *gtsmodel.Status) e } // now stream the notification to the user - mastoNotif, err := p.tc.NotificationToMasto(ctx, notif) + apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif) if err != nil { - return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) + return fmt.Errorf("notifyStatus: error converting notification to api representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, m.TargetAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(apiNotif, m.TargetAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } } @@ -143,12 +143,12 @@ func (p *processor) notifyFollowRequest(ctx context.Context, followRequest *gtsm } // now stream the notification to the user - mastoNotif, err := p.tc.NotificationToMasto(ctx, notif) + apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif) if err != nil { - return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) + return fmt.Errorf("notifyStatus: error converting notification to api representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, targetAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(apiNotif, targetAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } @@ -189,12 +189,12 @@ func (p *processor) notifyFollow(ctx context.Context, follow *gtsmodel.Follow, t } // now stream the notification to the user - mastoNotif, err := p.tc.NotificationToMasto(ctx, notif) + apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif) if err != nil { - return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) + return fmt.Errorf("notifyStatus: error converting notification to api representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, targetAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(apiNotif, targetAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } @@ -237,12 +237,12 @@ func (p *processor) notifyFave(ctx context.Context, fave *gtsmodel.StatusFave) e } // now stream the notification to the user - mastoNotif, err := p.tc.NotificationToMasto(ctx, notif) + apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif) if err != nil { - return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) + return fmt.Errorf("notifyStatus: error converting notification to api representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, targetAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(apiNotif, targetAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } @@ -316,12 +316,12 @@ func (p *processor) notifyAnnounce(ctx context.Context, status *gtsmodel.Status) } // now stream the notification to the user - mastoNotif, err := p.tc.NotificationToMasto(ctx, notif) + apiNotif, err := p.tc.NotificationToAPINotification(ctx, notif) if err != nil { - return fmt.Errorf("notifyStatus: error converting notification to masto representation: %s", err) + return fmt.Errorf("notifyStatus: error converting notification to api representation: %s", err) } - if err := p.streamingProcessor.StreamNotificationToAccount(mastoNotif, status.BoostOfAccount); err != nil { + if err := p.streamingProcessor.StreamNotificationToAccount(apiNotif, status.BoostOfAccount); err != nil { return fmt.Errorf("notifyStatus: error streaming notification to account: %s", err) } @@ -414,21 +414,21 @@ func (p *processor) timelineStatusForAccount(ctx context.Context, status *gtsmod // the status was inserted to stream it to the user if inserted { - mastoStatus, err := p.tc.StatusToMasto(ctx, status, timelineAccount) + apiStatus, err := p.tc.StatusToAPIStatus(ctx, status, timelineAccount) if err != nil { errors <- fmt.Errorf("timelineStatusForAccount: error converting status %s to frontend representation: %s", status.ID, err) } else { - if err := p.streamingProcessor.StreamStatusToAccount(mastoStatus, timelineAccount); err != nil { + if err := p.streamingProcessor.StreamUpdateToAccount(apiStatus, timelineAccount); err != nil { errors <- fmt.Errorf("timelineStatusForAccount: error streaming status %s: %s", status.ID, err) } } } - mastoStatus, err := p.tc.StatusToMasto(ctx, status, timelineAccount) + apiStatus, err := p.tc.StatusToAPIStatus(ctx, status, timelineAccount) if err != nil { errors <- fmt.Errorf("timelineStatusForAccount: error converting status %s to frontend representation: %s", status.ID, err) } else { - if err := p.streamingProcessor.StreamStatusToAccount(mastoStatus, timelineAccount); err != nil { + if err := p.streamingProcessor.StreamUpdateToAccount(apiStatus, timelineAccount); err != nil { errors <- fmt.Errorf("timelineStatusForAccount: error streaming status %s: %s", status.ID, err) } } -- cgit v1.2.3