Browse Source

remove bart flags check from RetrieveItem.RetrieveItem

Previously, RetrieveItem would return an error if it received an item
request with any flags set. The original thinking was that this method
should only receive requests for "known" BART item types.

Recently, a bug surfaced on Chivanet where a client, who had set a buddy
icon via iChat with flag 0x01 ("custom"), would force its buddies to
disconnect every time it signed on, because RetrieveItem did not accept
the flags.

It's not clear why RetrieveItem would take any flag into consideration.
This commit removes the check for now. Maybe it will become apparent in
the future why flags are passed to the RetrieveItem request.
Mike 2 years ago
parent
commit
2201e128ab
2 changed files with 3 additions and 29 deletions
  1. 3 8
      foodgroup/bart.go
  2. 0 21
      foodgroup/bart_test.go

+ 3 - 8
foodgroup/bart.go

@@ -3,7 +3,6 @@ package foodgroup
 import (
 	"context"
 	"crypto/md5"
-	"errors"
 	"fmt"
 	"log/slog"
 
@@ -19,9 +18,6 @@ var blankGIF = []byte{
 	0x32, 0x00, 0x32, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b,
 }
 
-// errKnownIconsOnly indicates that a non-known buddy icon was requested
-var errKnownIconsOnly = errors.New("can only satisfy requests for known icons")
-
 func NewBARTService(logger *slog.Logger, bartManager BARTManager, messageRelayer MessageRelayer, feedbagManager FeedbagManager, legacyBuddyListManager LegacyBuddyListManager) BARTService {
 	return BARTService{
 		bartManager:            bartManager,
@@ -72,11 +68,10 @@ func (s BARTService) UpsertItem(ctx context.Context, sess *state.Session, inFram
 	}, nil
 }
 
+// RetrieveItem fetches a BART item from the data store. The item is selected
+// based on inBody.Hash. It's unclear what effect inBody.Flags is supposed to
+// have on the request.
 func (s BARTService) RetrieveItem(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, inBody wire.SNAC_0x10_0x04_BARTDownloadQuery) (wire.SNACMessage, error) {
-	if inBody.Flags != wire.BARTFlagsKnown {
-		return wire.SNACMessage{}, errKnownIconsOnly
-	}
-
 	var icon []byte
 	if inBody.HasClearIconHash() {
 		icon = blankGIF

+ 0 - 21
foodgroup/bart_test.go

@@ -205,27 +205,6 @@ func TestBARTService_RetrieveItem(t *testing.T) {
 				},
 			},
 		},
-		{
-			name:        "retrieve unknown icon, expect err",
-			userSession: newTestSession("user_screen_name"),
-			inputSNAC: wire.SNACMessage{
-				Frame: wire.SNACFrame{
-					RequestID: 1234,
-				},
-				Body: wire.SNAC_0x10_0x04_BARTDownloadQuery{
-					ScreenName: "user_screen_name",
-					Command:    1,
-					BARTID: wire.BARTID{
-						Type: wire.BARTTypesBuddyIcon,
-						BARTInfo: wire.BARTInfo{
-							Flags: wire.BARTFlagsUnknown,
-							Hash:  wire.GetClearIconHash(),
-						},
-					},
-				},
-			},
-			expectErr: errKnownIconsOnly,
-		},
 	}
 
 	for _, tc := range cases {