async def receive_events(self, request: HttpRequest):
body = await request.read()<EOL>s = self.settings()<EOL>try:<EOL><INDENT>content = ujson.loads(body)<EOL><DEDENT>except ValueError:<EOL><INDENT>return json_response({<EOL>'<STR_LIT:error>': True,<EOL>'<STR_LIT:message>': '<STR_LIT>'<EOL>}, status=<NUM_LIT>)<EOL><DEDENT>secret = s['<STR_LIT>']<EOL>actual_sig = request.headers['<STR_LIT>']<EOL>expected_sig = sign_message(body, secret)<EOL>if not hmac.compare_digest(actual_sig, expected_sig):<EOL><INDENT>return json_response({<EOL>'<STR_LIT:error>': True,<EOL>'<STR_LIT:message>': '<STR_LIT>',<EOL>}, status=<NUM_LIT>)<EOL><DEDENT>for entry in content['<STR_LIT>']:<EOL><INDENT>for raw_message in entry.get('<STR_LIT>', []):<EOL><INDENT>message = FacebookMessage(raw_message, self)<EOL>await self.handle_event(message)<EOL><DEDENT><DEDENT>return json_response({<EOL>'<STR_LIT>': True,<EOL>})<EOL>
Events received from Facebook