Skip to content

Commit e12aa41

Browse files
committed
Add FCM token parameter to async endpoint
1 parent 1c398be commit e12aa41

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

go_capture/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def debug_task(self):
2727

2828

2929
@app.task
30-
def process_image_task(image_filename):
30+
def process_image_task(image_filename, fcm_token):
31+
print(f'token: {fcm_token}')
3132
sgf_filename = f'{Path(image_filename).stem}.sgf'
3233
sgf_path = settings.SGF_DIR / sgf_filename
3334
with open(image_filename, 'rb') as image_file:

go_capture/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def capture(request):
2828
@require_POST
2929
def capture_async(request):
3030
image_file = request.FILES['image']
31+
fcm_token = request.POST['fcm_registration_token']
32+
print(f'token: {fcm_token}')
3133
filename = Path(image_file.name)
3234
output_path = settings.IMAGES_DIR / filename
3335
with output_path.open('wb') as output_file:
3436
output_file.write(image_file.read())
35-
process_image_task.delay(str(output_path.absolute()))
37+
process_image_task.delay(str(output_path.absolute()), fcm_token)
3638
return HttpResponse(status=201)
3739

3840

requests.http

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Content-Type: image/jpeg
1616
POST {{protocol}}{{host}}:{{port}}/capture_async/
1717
Content-Type: multipart/form-data; boundary=WebAppBoundary
1818

19+
--WebAppBoundary
20+
Content-Disposition: form-data; name="fcm_registration_token"
21+
Content-Type: text/plain
22+
23+
foobar
24+
1925
--WebAppBoundary
2026
Content-Disposition: form-data; name="image"; filename="board.jpg"
2127
Content-Type: image/jpeg

0 commit comments

Comments
 (0)