File tree Expand file tree Collapse file tree 2 files changed +25
-10
lines changed
Expand file tree Collapse file tree 2 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ private static function updateFBUserIdFromVC(
245245 );
246246 $user_id = ZERO_FBID ;
247247 } else {
248- $user_id = $vc -> getUserID ();
248+ $user_id = $vc -> getAccountID ();
249249 }
250250
251251 if ($user_id !== ZERO_FBID && self :: updateFBUserId($user_id , $src )) {
@@ -263,6 +263,25 @@ private static function updateIGUserIdFromVC(
263263 return self :: updateIGUserId($vc -> getViewerID(), $src );
264264 }
265265
266+ private static function getIgUserId (int $ig_user_id ): ?int {
267+ if (IgidUtils :: isUserFbid($ig_user_id )) {
268+ return $ig_user_id ;
269+ }
270+ try {
271+ if (IgidUtils :: isUserIgid($ig_user_id )) {
272+ return IgidUtils :: userIgidToFbid($ig_user_id );
273+ }
274+ } catch (\ Exception $ex ) {
275+ ope (
276+ $ex ,
277+ causes_the (' No valid fbid for ig user id' )-> to(
278+ ' context proper user id' ,
279+ ),
280+ );
281+ }
282+ return null ;
283+ }
284+
266285 // returns id if it is valid (non-null, positive), and should match the type
267286 private static function coerceId (
268287 ?int $user_id ,
@@ -279,11 +298,7 @@ private static function coerceId(
279298 }
280299 break ;
281300 case UserIdCategory :: IG :
282- if (
283- IgidUtils :: isUserFbid($user_id ) || IgidUtils :: isUserIgid($user_id )
284- ) {
285- return $user_id ;
286- }
301+ return self :: getIgUserId($user_id );
287302 }
288303 return null ;
289304 }
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ public function testInitialization()[defaults]: void {
231231 );
232232
233233 // set up mocks for VC
234- $fb_vc = mock (IFBViewerContext :: class )-> mockReturn(' getUserID ' , fbid (1 ));
234+ $fb_vc = mock (IFBViewerContext :: class )-> mockReturn(' getAccountID ' , fbid (1 ));
235235 $ig_vc = mock (IIGViewerContext :: class )-> mockReturn(' getViewerID' , fbid (2 ));
236236
237237 $buf = new TMemoryBuffer ();
@@ -260,7 +260,8 @@ public function testInitialization()[defaults]: void {
260260 );
261261
262262 // set up mocks for VC
263- $fb_vc = mock (IFBViewerContext :: class )-> mockReturn(' getUserID' , fbid (123 ));
263+ $fb_vc =
264+ mock (IFBViewerContext :: class )-> mockReturn(' getAccountID' , fbid (123 ));
264265
265266 $buf = new TMemoryBuffer ();
266267 $prot = new TCompactProtocolAccelerated ($buf );
@@ -286,9 +287,8 @@ public function testInitialization()[defaults]: void {
286287 $tfm -> baggage -> user_ids = ContextProp \UserIds :: fromShape(
287288 shape (' fb_user_id' => 123 , ' ig_user_id' => 456 ),
288289 );
289-
290290 // set up mocks for VC
291- $fb_vc = mock (IFBViewerContext :: class )-> mockReturn(' getUserID ' , fbid (1 ));
291+ $fb_vc = mock (IFBViewerContext :: class )-> mockReturn(' getAccountID ' , fbid (1 ));
292292 $ig_vc = mock (IIGViewerContext :: class )-> mockReturn(' getViewerID' , fbid (2 ));
293293
294294 $buf = new TMemoryBuffer ();
You can’t perform that action at this time.
0 commit comments