From 38be131a7a18a4a2148758fb3da379a431c1066a Mon Sep 17 00:00:00 2001 From: Jordan Reedie Date: Mon, 10 Dec 2018 21:44:35 -0500 Subject: [PATCH 1/2] get_meeting fix for log version 2.1 --- openbadge-server/openbadge/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openbadge-server/openbadge/models.py b/openbadge-server/openbadge/models.py index 7357ed9..993100c 100644 --- a/openbadge-server/openbadge/models.py +++ b/openbadge-server/openbadge/models.py @@ -475,7 +475,14 @@ def get_meta(self): while "received" not in line["type"] and "ended" not in line["type"]: # make sure we're getting a member change event # ANYTHING IS POSSIBLE - if "member" in line["type"] and line["data"]["change"] == "join": + # in log version 2.0 the type is "member changed" and you need to check + # the `change` property + log_v20_join = line["type"] == "member changed" and line["data"]["change"] == "join" + + # in log version 2.1 the type is just "member joined" and it has no `change` property + log_v21_join = line["type"] == "member joined" + + if log_v20_join or log_v21_join: meta["members"].append(line["data"]["member_key"]) try: line = simplejson.loads(f.readline()) From 8d08da22a6ceaab580c9b59c8ea4b685b493e21f Mon Sep 17 00:00:00 2001 From: Jordan Reedie Date: Tue, 11 Dec 2018 15:43:47 -0500 Subject: [PATCH 2/2] ah, missed a spot (member_key -> key) --- openbadge-server/openbadge/models.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/openbadge-server/openbadge/models.py b/openbadge-server/openbadge/models.py index 993100c..417bbb5 100644 --- a/openbadge-server/openbadge/models.py +++ b/openbadge-server/openbadge/models.py @@ -468,6 +468,7 @@ def get_meta(self): meta["members"] = [] + log_version = meta["data"]["log_version"] # seek to beginning in case it was written out of order f.seek(0) # the following few lines should be members joining @@ -475,15 +476,16 @@ def get_meta(self): while "received" not in line["type"] and "ended" not in line["type"]: # make sure we're getting a member change event # ANYTHING IS POSSIBLE - # in log version 2.0 the type is "member changed" and you need to check - # the `change` property - log_v20_join = line["type"] == "member changed" and line["data"]["change"] == "join" - - # in log version 2.1 the type is just "member joined" and it has no `change` property - log_v21_join = line["type"] == "member joined" - - if log_v20_join or log_v21_join: + if log_version == "2.0" and line["type"] == "member changed" and line["data"]["change"] == "join": + # in log version 2.0 the type is "member changed" + # and you need to check the `change` property meta["members"].append(line["data"]["member_key"]) + elif log_version == "2.1" and line["type"] == "member joined": + # in log version 2.1 the type is just "member joined" + # and it has no `change` property + # also it uses `key` instead of `member_key` + meta["members"].append(line["data"]["key"]) + try: line = simplejson.loads(f.readline()) if not line: break