Fix GraphQL user crash with invalid JSON
This commit is contained in:
		
							parent
							
								
									38985af6ed
								
							
						
					
					
						commit
						dcf73354ff
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -4,6 +4,9 @@ import user, ../types/[graphuser, graphlistmembers]
 | 
			
		|||
from ../../types import User, Result, Query, QueryKind
 | 
			
		||||
 | 
			
		||||
proc parseGraphUser*(json: string): User =
 | 
			
		||||
  if json.len == 0 or json[0] != '{':
 | 
			
		||||
    return
 | 
			
		||||
 | 
			
		||||
  let raw = json.fromJson(GraphUser)
 | 
			
		||||
 | 
			
		||||
  if raw.data.user.result.reason.get("") == "Suspended":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue