Просмотр исходного кода

icq: authRequired is true when 0

Mike 3 месяцев назад
Родитель
Сommit
1813e0fb4a
3 измененных файлов с 56 добавлено и 4 удалено
  1. 1 1
      foodgroup/icq.go
  2. 54 2
      foodgroup/icq_test.go
  3. 1 1
      server/icq_legacy/v3_handler.go

+ 1 - 1
foodgroup/icq.go

@@ -566,7 +566,7 @@ func (s ICQService) SetMoreInfo(ctx context.Context, instance *state.SessionInst
 
 func (s ICQService) SetPermissions(ctx context.Context, instance *state.SessionInstance, inBody wire.ICQ_0x07D0_0x0424_DBQueryMetaReqSetPermissions, seq uint16) error {
 	u := state.ICQPermissions{
-		AuthRequired: inBody.Authorization == 1,
+		AuthRequired: inBody.Authorization == 0,
 		WebAware:     inBody.WebAware == 1,
 	}
 

+ 54 - 2
foodgroup/icq_test.go

@@ -2610,11 +2610,11 @@ func TestICQService_SetPermissions(t *testing.T) {
 		wantErr    error
 	}{
 		{
-			name:     "happy path",
+			name:     "authorization required",
 			seq:      1,
 			instance: newTestInstance("100003", sessOptUIN(100003)),
 			req: wire.ICQ_0x07D0_0x0424_DBQueryMetaReqSetPermissions{
-				Authorization: 1,
+				Authorization: 0,
 				WebAware:      1,
 			},
 			mockParams: mockParams{
@@ -2661,6 +2661,58 @@ func TestICQService_SetPermissions(t *testing.T) {
 				},
 			},
 		},
+		{
+			name:     "authorization required",
+			seq:      1,
+			instance: newTestInstance("100003", sessOptUIN(100003)),
+			req: wire.ICQ_0x07D0_0x0424_DBQueryMetaReqSetPermissions{
+				Authorization: 1,
+				WebAware:      1,
+			},
+			mockParams: mockParams{
+				icqUserUpdaterParams: icqUserUpdaterParams{
+					setPermissionsParams: setPermissionsParams{
+						{
+							name: state.NewIdentScreenName("100003"),
+							data: state.ICQPermissions{
+								AuthRequired: false,
+								WebAware:     true,
+							},
+						},
+					},
+				},
+				messageRelayerParams: messageRelayerParams{
+					relayToScreenNameParams: relayToScreenNameParams{
+						{
+							screenName: state.NewIdentScreenName("100003"),
+							message: wire.SNACMessage{
+								Frame: wire.SNACFrame{
+									FoodGroup: wire.ICQ,
+									SubGroup:  wire.ICQDBReply,
+								},
+								Body: wire.SNAC_0x15_0x02_DBReply{
+									TLVRestBlock: wire.TLVRestBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.ICQTLVTagsMetadata, wire.ICQMessageReplyEnvelope{
+												Message: wire.ICQ_0x07DA_0x00DC_DBQueryMetaReplyMoreInfo{
+													ICQMetadata: wire.ICQMetadata{
+														UIN:     100003,
+														ReqType: wire.ICQDBQueryMetaReply,
+														Seq:     1,
+													},
+													ReqSubType: wire.ICQDBQueryMetaReplySetPermissions,
+													Success:    wire.ICQStatusCodeOK,
+												},
+											}),
+										},
+									},
+								},
+							},
+						},
+					},
+				},
+			},
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {

+ 1 - 1
server/icq_legacy/v3_handler.go

@@ -1095,7 +1095,7 @@ func (h *V3Handler) handleSetHomeInfo(session *LegacySession, seq1, seq2 uint16,
 			h.logger.Error("V3 set home info failed", "uin", uin, "err", err)
 		}
 	}
-	if err := h.service.SetAuthMode(ctx, uin, auth == 1); err != nil {
+	if err := h.service.SetAuthMode(ctx, uin, auth == 0); err != nil {
 		h.logger.Error("V3 set home auth failed", "uin", uin, "err", err)
 	}