diff --git a/main.go b/main.go index b8d5125..65923d3 100644 --- a/main.go +++ b/main.go @@ -230,7 +230,12 @@ func main() { if service, ok := serviceManager.GetService(snac.Header.Family); ok { newCtx, err := service.HandleSNAC(ctx, db, snac) - util.PanicIfError(err) + if err != nil { + log.Printf("encountered error: %s", err) + session.Disconnect() + handleCloseFn(ctx, session) + } + return newCtx } } else if flap.Header.Channel == 4 { diff --git a/services/0x02_location_services.go b/services/0x02_location_services.go index 2772b0e..2a038c8 100644 --- a/services/0x02_location_services.go +++ b/services/0x02_location_services.go @@ -52,7 +52,6 @@ func (s *LocationServices) HandleSNAC(ctx context.Context, db *bun.DB, snac *osc } user.AwayMessage = string(awayMessageTLV.Data) user.AwayMessageEncoding = string(awayMessageMimeTLV.Data) - } profileTLV := oscar.FindTLV(tlvs, 0x2) @@ -95,6 +94,14 @@ func (s *LocationServices) HandleSNAC(ctx context.Context, db *bun.DB, snac *osc if err != nil { return ctx, aimerror.FetchingUser(err, requestedScreenName) } + if requestedUser == nil { + noMatchSnac := oscar.NewSNAC(0x2, 1) + noMatchSnac.Data.WriteUint16(0x14) // error code 0x14: No Match + noMatchFlap := oscar.NewFLAP(2) + noMatchFlap.Data.WriteBinary(noMatchSnac) + session.Send(noMatchFlap) + return ctx, nil + } respSnac := oscar.NewSNAC(2, 6) respSnac.Data.WriteLPString(requestedUser.ScreenName) diff --git a/services/0x03_buddy_list_management.go b/services/0x03_buddy_list_management.go index ce16eca..2d0a5da 100644 --- a/services/0x03_buddy_list_management.go +++ b/services/0x03_buddy_list_management.go @@ -48,7 +48,12 @@ func (b *BuddyListManagement) HandleSNAC(ctx context.Context, db *bun.DB, snac * return ctx, errors.Wrap(err, "error looking for User") } if buddy == nil { - return ctx, aimerror.UserNotFound(buddyScreename) + noMatchSnac := oscar.NewSNAC(0x3, 1) + noMatchSnac.Data.WriteUint16(0x14) // error code 0x14: No Match + noMatchFlap := oscar.NewFLAP(2) + noMatchFlap.Data.WriteBinary(noMatchSnac) + session.Send(noMatchFlap) + return ctx, nil } rel := &models.Buddy{ @@ -84,7 +89,12 @@ func (b *BuddyListManagement) HandleSNAC(ctx context.Context, db *bun.DB, snac * return ctx, errors.Wrap(err, "error looking for User") } if buddy == nil { - return ctx, aimerror.UserNotFound(buddyScreename) + noMatchSnac := oscar.NewSNAC(0x3, 1) + noMatchSnac.Data.WriteUint16(0x14) // error code 0x14: No Match + noMatchFlap := oscar.NewFLAP(2) + noMatchFlap.Data.WriteBinary(noMatchSnac) + session.Send(noMatchFlap) + return ctx, nil } _, err = db.NewDelete().Model((*models.Buddy)(nil)).Where("source_uin = ?", user.UIN).Where("with_uin = ?", buddy.UIN).Exec(ctx)