diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-03 20:48:05 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-03 20:48:05 -0700 |
| commit | 38f710ec30445df4a4d34ce0d3193e4ed4aa79c9 (patch) | |
| tree | 12e043a9cbb72066b1b8041e0345a31898c94a72 /hotline/transaction_handlers_test.go | |
| parent | d29edb0a25c577f6490f21844fa13e13ba3e731e (diff) | |
Implement "Refuse private messages" client preference
Diffstat (limited to 'hotline/transaction_handlers_test.go')
| -rw-r--r-- | hotline/transaction_handlers_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index e141c78..fd66fea 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -2302,6 +2302,7 @@ func TestHandleSendInstantMsg(t *testing.T) { Clients: map[uint16]*ClientConn{ uint16(2): { AutoReply: []byte(nil), + Flags: []byte{0, 0}, }, }, }, @@ -2350,6 +2351,7 @@ func TestHandleSendInstantMsg(t *testing.T) { Server: &Server{ Clients: map[uint16]*ClientConn{ uint16(2): { + Flags: []byte{0, 0}, ID: &[]byte{0, 2}, UserName: []byte("User2"), AutoReply: []byte("autohai"), @@ -2393,6 +2395,57 @@ func TestHandleSendInstantMsg(t *testing.T) { }, wantErr: assert.NoError, }, + { + name: "when client 2 has refuse private messages enabled", + args: args{ + cc: &ClientConn{ + Account: &Account{ + Access: func() accessBitmap { + var bits accessBitmap + bits.Set(accessSendPrivMsg) + return bits + }(), + }, + ID: &[]byte{0, 1}, + UserName: []byte("User1"), + Server: &Server{ + Clients: map[uint16]*ClientConn{ + uint16(2): { + Flags: []byte{255, 255}, + ID: &[]byte{0, 2}, + UserName: []byte("User2"), + }, + }, + }, + }, + t: NewTransaction( + tranSendInstantMsg, + &[]byte{0, 1}, + NewField(fieldData, []byte("hai")), + NewField(fieldUserID, []byte{0, 2}), + ), + }, + wantRes: []Transaction{ + *NewTransaction( + tranServerMsg, + &[]byte{0, 1}, + NewField(fieldData, []byte("User2 does not accept private messages.")), + NewField(fieldUserName, []byte("User2")), + NewField(fieldUserID, []byte{0, 2}), + NewField(fieldOptions, []byte{0, 2}), + ), + { + clientID: &[]byte{0, 1}, + Flags: 0x00, + IsReply: 0x01, + Type: []byte{0x0, 0x6c}, + ID: []byte{0, 0, 0, 0}, + ErrorCode: []byte{0, 0, 0, 0}, + Fields: []Field(nil), + }, + }, + wantErr: assert.NoError, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { |