Skip to content

Commit 9282926

Browse files
committed
Added route to see user's likes
1 parent b40e4e2 commit 9282926

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

PyMatcha.postman_collection.json

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,38 @@
40634063
}
40644064
},
40654065
"response": []
4066+
},
4067+
{
4068+
"name": "Get sent and received likes",
4069+
"event": [
4070+
{
4071+
"listen": "test",
4072+
"script": {
4073+
"id": "42cca1eb-0433-4709-a922-7037e6ddc6d5",
4074+
"exec": [
4075+
"var response = JSON.parse(responseBody);",
4076+
"",
4077+
"tests[\"Received likes != 0\"] = response.likes.received.length != 0",
4078+
"tests[\"Sent likes != 0\"] = response.likes.sent.length != 0"
4079+
],
4080+
"type": "text/javascript"
4081+
}
4082+
}
4083+
],
4084+
"request": {
4085+
"method": "GET",
4086+
"header": [],
4087+
"url": {
4088+
"raw": "{{host}}/likes",
4089+
"host": [
4090+
"{{host}}"
4091+
],
4092+
"path": [
4093+
"likes"
4094+
]
4095+
}
4096+
},
4097+
"response": []
40664098
}
40674099
],
40684100
"protocolProfileBehavior": {}
@@ -4225,109 +4257,109 @@
42254257
],
42264258
"variable": [
42274259
{
4228-
"id": "af6aee14-6e91-4d11-8b5c-e8cc1438311d",
4260+
"id": "28a23486-a04f-4122-83dd-7876ef955760",
42294261
"key": "host",
42304262
"value": "http://127.0.0.1:5000",
42314263
"type": "string"
42324264
},
42334265
{
4234-
"id": "fdea782c-2dab-4410-b65a-73a1a22c73ea",
4266+
"id": "5f84e9ec-b6ef-4677-9c5b-55d4fdfce50b",
42354267
"key": "user_id",
42364268
"value": "",
42374269
"type": "string"
42384270
},
42394271
{
4240-
"id": "f0404a42-abab-428a-872e-c0e0e71df739",
4272+
"id": "2050da02-1090-484a-a476-7094e90d6d1a",
42414273
"key": "user_email",
42424274
"value": "foo@example.org",
42434275
"type": "string"
42444276
},
42454277
{
4246-
"id": "289e6da9-63c2-405c-aa04-dc1e7c944ae7",
4278+
"id": "860f9ba6-0925-4cb1-95c9-a97242b5fd9b",
42474279
"key": "user_username",
42484280
"value": "foo",
42494281
"type": "string"
42504282
},
42514283
{
4252-
"id": "106fef29-98b9-46e3-aa0c-2a720d018604",
4284+
"id": "c77043d9-6185-4fc1-b683-174505689ad3",
42534285
"key": "user_password",
42544286
"value": "admin",
42554287
"type": "string"
42564288
},
42574289
{
4258-
"id": "a6221612-0ff9-4299-b316-54f0f501dcec",
4290+
"id": "d81b203b-9f7f-43ff-b6d4-712b935d893f",
42594291
"key": "user_firstname",
42604292
"value": "Foo",
42614293
"type": "string"
42624294
},
42634295
{
4264-
"id": "939c43d6-9dad-4e7e-96ce-09c831499a1e",
4296+
"id": "ea2ca3b3-5f0e-4bba-9aac-ead08085e0bb",
42654297
"key": "user_lastname",
42664298
"value": "Bar",
42674299
"type": "string"
42684300
},
42694301
{
4270-
"id": "2544a319-3ac2-4083-9665-42b5bab9df10",
4302+
"id": "ff0c8637-acc0-41d1-bc2f-e7e82d4ae088",
42714303
"key": "debug_token",
42724304
"value": "xX69jules69Xx",
42734305
"type": "string"
42744306
},
42754307
{
4276-
"id": "fcbb3982-a60a-4797-9d53-7805b775d380",
4308+
"id": "94f1a459-158b-46e3-a78d-78e84507c291",
42774309
"key": "user_access_token",
42784310
"value": "",
42794311
"type": "string"
42804312
},
42814313
{
4282-
"id": "9f004407-c35e-4556-a22a-747fdf0b9f79",
4314+
"id": "283378eb-bf66-41f9-8ac0-54a2e4578e7f",
42834315
"key": "user_refresh_token",
42844316
"value": "",
42854317
"type": "string"
42864318
},
42874319
{
4288-
"id": "a07c4180-3179-4aff-8575-46fb9e42ea83",
4320+
"id": "4202671c-ac1f-45df-9861-00b5f1d0faec",
42894321
"key": "expired_token",
42904322
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1OTAyNDIyNjQsIm5iZiI6MTU5MDI0MjI2NCwianRpIjoiNTM0ZGI5NzQtOWE4Ni00MGViLWE1NDEtMDg3N2ZmNzQ3NDVhIiwiZXhwIjoxNTkwMjQyMzI0LCJpZGVudGl0eSI6eyJpZCI6NTEyLCJlbWFpbCI6ImZvb0BleGFtcGxlLm9yZyIsInVzZXJuYW1lIjoiYmFyIiwiaXNfb25saW5lIjp0cnVlLCJkYXRlX2xhc3RzZWVuIjoiU2F0LCAyMyBNYXkgMjAyMCAxMzo1Nzo0NCBHTVQifSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.NTp2P0WNkXDwzuzrcNIQdeAfizQ57HQgkzBLSvY1yHU",
42914323
"type": "string"
42924324
},
42934325
{
4294-
"id": "4ba17b0e-8325-4a02-ae90-01c4a4f499f1",
4326+
"id": "d93bf868-d915-4b0f-9a40-13542742acb8",
42954327
"key": "user_orientation",
42964328
"value": "heterosexual",
42974329
"type": "string"
42984330
},
42994331
{
4300-
"id": "d6d9c37f-da1a-4c4e-afa2-f9214637e13c",
4332+
"id": "e8511aa0-b6a1-4946-bc68-1a637277989e",
43014333
"key": "user_bio",
43024334
"value": "Lorem Ipsum is the single greatest threat. We are not - we are not keeping up with other websites. Lorem Ipsum best not make any more threats to your website. It will be met with fire and fury like the world has never seen. Does everybody know that pig named Lorem Ipsum? An ‘extremely credible source’ has called my office and told me that Barack Obama’s placeholder text is a fraud.",
43034335
"type": "string"
43044336
},
43054337
{
4306-
"id": "d3900cb1-01d2-4915-9ce8-37d1d790b560",
4338+
"id": "711df570-f4d8-4253-9bb3-90f6428a2923",
43074339
"key": "user_gender",
43084340
"value": "male",
43094341
"type": "string"
43104342
},
43114343
{
4312-
"id": "ed9ccd93-a2ab-4dd0-9b68-57477110cbf1",
4344+
"id": "2c1e8e72-e272-472c-a316-a4e2d32feb52",
43134345
"key": "user_birthdate",
43144346
"value": "06/04/1998",
43154347
"type": "string"
43164348
},
43174349
{
4318-
"id": "e117a4aa-6f76-4715-bdb3-8023b1d74f81",
4350+
"id": "55317914-201d-40d6-923a-e250a0733436",
43194351
"key": "user_lat",
43204352
"value": "44.8404",
43214353
"type": "string"
43224354
},
43234355
{
4324-
"id": "bf8a919e-2fe7-4139-b82c-b215ea6584b3",
4356+
"id": "82fe60ef-d805-4317-ba54-a511524ba7ac",
43254357
"key": "user_lng",
43264358
"value": "-0.5805",
43274359
"type": "string"
43284360
},
43294361
{
4330-
"id": "6208b5f1-e496-4642-9e38-4faa9b4e950d",
4362+
"id": "e5163790-a8e8-482e-aafa-567565e5b0a8",
43314363
"key": "user_ip",
43324364
"value": "77.205.46.181",
43334365
"type": "string"

backend/PyMatcha/routes/api/like.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from PyMatcha.utils.errors import BadRequestError
88
from PyMatcha.utils.errors import NotFoundError
99
from PyMatcha.utils.success import Success
10+
from PyMatcha.utils.success import SuccessOutput
1011

1112
like_bp = Blueprint("like", __name__)
1213

@@ -46,5 +47,10 @@ def unlike_profile(uid):
4647
return Success(f"Unliked user {u.id}.")
4748

4849

49-
# TODO: Likes received
50-
# TODO: Likes sent
50+
@like_bp.route("/likes", methods=["GET"])
51+
@jwt_required
52+
def see_my_likes():
53+
received = current_user.get_likes_received()
54+
sent = current_user.get_likes_sent()
55+
returned_dict = {"received": [r.to_dict() for r in received], "sent": [s.to_dict() for s in sent]}
56+
return SuccessOutput("likes", returned_dict)

0 commit comments

Comments
 (0)