fix TLV construction in message delivery. users can now chat

This commit is contained in:
Artem Titoulenko 2021-12-19 02:23:43 -05:00
parent 00c2f20caf
commit cca7d63e20
3 changed files with 14 additions and 14 deletions

View file

@ -60,8 +60,8 @@ func (g *GenericServiceControls) HandleSNAC(ctx context.Context, db *bun.DB, sna
onlineSnac.Data.WriteUint16(0) // TODO: user warning level
tlvs := []*oscar.TLV{
oscar.NewTLV(1, util.Word(0x80)), // TODO: user class
oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status
oscar.NewTLV(1, util.Word(0)), // TODO: user class
oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status
oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP
oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time
oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time
@ -142,7 +142,7 @@ func (g *GenericServiceControls) HandleSNAC(ctx context.Context, db *bun.DB, sna
tlvs := []*oscar.TLV{
oscar.NewTLV(0x01, util.Dword(0x80)), // User Class
oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status
oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status
oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP
oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time
oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time

View file

@ -34,8 +34,8 @@ func MessageDelivery() (chan *models.Message, routineFn) {
messageSnac.Data.WriteUint16(0) // TODO: sender's warning level
tlvs := []*oscar.TLV{
oscar.NewTLV(1, util.Word(0x80)), // TODO: user class
oscar.NewTLV(6, util.Dword(0x0001|0x0100)), // TODO: user status
oscar.NewTLV(1, util.Word(0)), // TODO: user class
oscar.NewTLV(6, util.Dword(0)), // TODO: user status
oscar.NewTLV(0xf, util.Dword(0)), // TODO: user idle time
oscar.NewTLV(3, util.Dword(0)), // TODO: user creation time
// oscar.NewTLV(4, []byte{}), // TODO: this TLV appears in automated responses like away messages
@ -50,14 +50,14 @@ func MessageDelivery() (chan *models.Message, routineFn) {
}
frag := oscar.Buffer{}
frag.Write([]byte{5, 1, 0, 4, 1, 1, 1, 1}) // TODO: first fragment [id, version, len, len, (cap * len)... ]
frag.Write([]byte{5, 1, 0, 4, 1, 1, 1, 2}) // TODO: first fragment [id, version, len, len, (cap * len)... ]
frag.Write([]byte{1, 1}) // message text fragment start (this is a busted "TLV")
frag.Write(util.Word(uint16(len(message.Contents) + 4))) // length of TLV
frag.WriteUint16(uint16(len(message.Contents) + 4)) // length of TLV
frag.Write([]byte{0, 0, 0, 0}) // TODO: message charset number, message charset subset
frag.WriteString(message.Contents)
// Append the fragments
messageSnac.Data.Write(frag.Bytes())
messageSnac.Data.WriteBinary(oscar.NewTLV(2, frag.Bytes()))
messageFlap := oscar.NewFLAP(2)
messageFlap.Data.WriteBinary(messageSnac)

View file

@ -43,8 +43,8 @@ func OnlineNotification() (chan *models.User, routineFn) {
onlineSnac.Data.WriteUint16(0) // TODO: user warning level
tlvs := []*oscar.TLV{
oscar.NewTLV(1, util.Word(0x80)), // TODO: user class
oscar.NewTLV(0x06, util.Dword(0x0001|0x0100)), // TODO: User Status
oscar.NewTLV(1, util.Word(0)), // TODO: user class
oscar.NewTLV(0x06, util.Dword(0x50)), // TODO: User Status
oscar.NewTLV(0x0a, util.Dword(binary.BigEndian.Uint32([]byte(SRV_HOST)))), // External IP
oscar.NewTLV(0x0f, util.Dword(uint32(time.Since(user.LastActivityAt).Seconds()))), // Idle Time
oscar.NewTLV(0x03, util.Dword(uint32(time.Now().Unix()))), // Client Signon Time