◢███◤      ◢██◤                            ◢██◤                            
     ◢██◤       ◢██◤                            ◢██◤                             
    ◢██◤       ◢██◤                            ◢██◤                              
   ◢██◤       ◢██◤                            ◢██◤                               
  ◢██◤       ◢██◤                            ◢██◤                                
◢███◤       ◢██◤                            ◢██◤                          ◥██◣   
◥███       ◢█████◣    ◢████████◤ ◢███████◤ ◢██◤ ◢██◤                 ◢██◤   ██◣  
 ███      ◢███████◣        ◢██◤ ◢██◤ ◢██◤ ◢███████◤                 ◢██◤    ███  
 ███     ◢██◤  ◢██◤ ◢████████◤ ◢██◤      ◢█████◣                   ◢██◤     ███  
 ███    ◢██◤  ◢██◤ ◢██◤  ███◤ ◢██◤ ◢██◤ ◢██◤◥███◣                 ◢██◤      ███  
 ◥██   ◢██◤  ◢██◤ ◢████████◤ ◢███████◤ ◢██◤  ◥███◣               ◢██◤       ███◣ 
  ◥██◣                                                          ◢██◤       ◢███◤ 
                                 ◢███◤ ◢███◤ ◢██◤  ◢██◤ ◢█████████◤       ◢██◤   
                                ◢█████████◤ ◢██◤  ◢██◤ ◢██◤  ████◤       ◢██◤    
                               ◢██◤◢█◤◢██◤ ◢██◤  ◢██◤ ◢██◤   ███◤       ◢██◤     
                              ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤       ◢██◤      
                             ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤      ◢███◤       

0005
chat api chat_history returns empty array if you did not join/leave the specified channel between the specified times
477r8n
If you use chat_history on a channel and your before/after timestamps span a time during which you never joined or left the channel (i.e. were passively in the entire time), you get no data back (empty array). leave and rejoin (and update before timestamp to be after those) and you get data back, including before you left (properly). A join/leave shouldn't be necessary in the time span in question to get data. Someone sitting in a channel passively should be able to chat_history it w/o having to leave/join periodically to keep that 'fresh'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Some theorycrafting as to why this bug happens: we are assuming that you can't store whether a suer is in a given channel for every possible time, so use is_join/is_leave  as a indicator for when someone is in a channel; without either of these flags in range, EITHER you were in the channel for the entire period or you weren't, but the chat API can't tell.  IF that is true, suggested fix: Step 1) Check for a is_join/is_leave in the range specified (as you do now); if either is present, at least some of the range has data we should get. Yay. Now go through the range to pick out all the valid sub-ranges. Step 2) If not, check for the first is_join/is_leave *before* the specified before data. If this exists and it is a is_join, all the specified range is data we should get (because we joined before BEFORE, and never left until after AFTER; if we had left we'd have stopped in step 1) Step 3) if not, check the first is_join/is_leave *after* the specified after date. If it is a is_leave, then the entire range is valid Step 4) if not, check if the user is in the channel *right now* (race conditions boo; maybe pull this data before step 1 to be safe). If they are, and since if we got here there are no joins or leaves since the beginning of the records, they must have been in the channel since the beginning of records, so the entire range is valid. If not they must never have been in the channel since the start of records and the entire range is invalid. If you get a "is valid" from steps 2-4, the *entire* range must be valid so no need to scan for noncontinuous chunks (as step 1 requires)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -