Skip to content

Commit

Permalink
pd: set permit/deny mode on empty list
Browse files Browse the repository at this point in the history
I ran into a situation where the permit-some and deny-some modes
are not set when the user list is empty. This behavior surfaced while
testing the TIK client. This does not occur in the regular OSCAR AIM
client because it sets "allow all" when the "deny some" list is empty
and "deny all" when the "permit some" list is empty.
  • Loading branch information
mk6i committed Dec 22, 2024
1 parent dcd9eaa commit 1ea668a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
8 changes: 0 additions & 8 deletions foodgroup/permit_deny.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ func (s PermitDenyService) AddDenyListEntries(
sess *state.Session,
body wire.SNAC_0x09_0x07_PermitDenyAddDenyListEntries,
) error {
if len(body.Users) == 0 {
return nil
}

if len(body.Users) == 1 {
sn := state.NewIdentScreenName(body.Users[0].ScreenName)
if sn.String() == sess.IdentScreenName().String() {
Expand Down Expand Up @@ -78,10 +74,6 @@ func (s PermitDenyService) AddPermListEntries(
sess *state.Session,
body wire.SNAC_0x09_0x05_PermitDenyAddPermListEntries,
) error {
if len(body.Users) == 0 {
return nil
}

if len(body.Users) == 1 {
sn := state.NewIdentScreenName(body.Users[0].ScreenName)
if sn.String() == sess.IdentScreenName().String() {
Expand Down
52 changes: 40 additions & 12 deletions foodgroup/permit_deny_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,26 @@ func TestPermitDenyService_AddDenyListEntries(t *testing.T) {
},
},
{
name: "set FeedbagPDModeDenySome - 0 users",
sess: newTestSession("me", sessOptSignonComplete),
bodyIn: wire.SNAC_0x09_0x07_PermitDenyAddDenyListEntries{
Users: []struct {
ScreenName string `oscar:"len_prefix=uint8"`
}{},
name: "set FeedbagPDModeDenySome - 0 users",
sess: newTestSession("me", sessOptSignonComplete),
bodyIn: wire.SNAC_0x09_0x07_PermitDenyAddDenyListEntries{},
mockParams: mockParams{
localBuddyListManagerParams: localBuddyListManagerParams{
setPDModeParams: setPDModeParams{
{
userScreenName: state.NewIdentScreenName("me"),
pdMode: wire.FeedbagPDModeDenySome,
},
},
},
buddyBroadcasterParams: buddyBroadcasterParams{
broadcastVisibilityParams: broadcastVisibilityParams{
{
from: state.NewIdentScreenName("me"),
filter: nil,
},
},
},
},
},
{
Expand Down Expand Up @@ -270,12 +284,26 @@ func TestPermitDenyService_AddPermListEntries(t *testing.T) {
},
},
{
name: "set FeedbagPDModePermitSome - 0 users",
sess: newTestSession("me", sessOptSignonComplete),
bodyIn: wire.SNAC_0x09_0x05_PermitDenyAddPermListEntries{
Users: []struct {
ScreenName string `oscar:"len_prefix=uint8"`
}{},
name: "set FeedbagPDModePermitSome - 0 users",
sess: newTestSession("me", sessOptSignonComplete),
bodyIn: wire.SNAC_0x09_0x05_PermitDenyAddPermListEntries{},
mockParams: mockParams{
localBuddyListManagerParams: localBuddyListManagerParams{
setPDModeParams: setPDModeParams{
{
userScreenName: state.NewIdentScreenName("me"),
pdMode: wire.FeedbagPDModePermitSome,
},
},
},
buddyBroadcasterParams: buddyBroadcasterParams{
broadcastVisibilityParams: broadcastVisibilityParams{
{
from: state.NewIdentScreenName("me"),
filter: nil,
},
},
},
},
},
{
Expand Down

0 comments on commit 1ea668a

Please sign in to comment.