Skip to content

Commit

Permalink
remove bart flags check from RetrieveItem.RetrieveItem
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mk6i committed Jun 22, 2024
1 parent 92b6d8a commit 2201e12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
11 changes: 3 additions & 8 deletions foodgroup/bart.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package foodgroup
import (
"context"
"crypto/md5"
"errors"
"fmt"
"log/slog"

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions foodgroup/bart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2201e12

Please sign in to comment.