Skip to content

Commit

Permalink
Remove redundant cleanup of journal faction info
Browse files Browse the repository at this point in the history
Clean up duplicate detection code
  • Loading branch information
Marginal committed Jan 8, 2019
1 parent 2e1881f commit be7fcc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
7 changes: 0 additions & 7 deletions src/eddn/Relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ def relay_worker(message):
if 'uploaderIP' in json['header']:
del json['header']['uploaderIP']

# Remove personal data from FSDJump and Location => MyReputation
if '/journal/' in json['$schemaRef'] and 'event' in json['message']:
if json['message']['event'] in ['FSDJump', 'Location'] and 'Factions' in json['message']:
for i, values in enumerate(json['message']['Factions']):
if 'MyReputation' in values:
del json['message']['Factions'][i]['MyReputation']

# Convert message back to JSON
message = simplejson.dumps(json, sort_keys=True)

Expand Down
17 changes: 7 additions & 10 deletions src/eddn/core/DuplicateMessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,20 @@ def isDuplicated(self, json):
'message': dict(json['message']),
}

# Convert starPos to avoid software modification in dupe messages
# Remove timestamp (Mainly to avoid multiple scan messages and faction influences)
jsonTest['message'].pop('timestamp')

# Convert journal starPos to avoid software modification in dupe messages
if 'StarPos' in jsonTest['message']:
jsonTest['message']['StarPos'] = [int(round(x * 32)) for x in jsonTest['message']['StarPos']]

# Prevent Docked event with small difference in distance from start
# Prevent journal Docked event with small difference in distance from start
if 'DistFromStarLS' in jsonTest['message']:
jsonTest['message']['DistFromStarLS'] = int(jsonTest['message']['DistFromStarLS'] + 0.5)

# Remove journal timestamp (Mainly to avoid multiple scan messages and faction influences)
if 'timestamp' in jsonTest['message']:
del jsonTest['message']['timestamp']

# Remove journal ScanType and DistanceFromArrivalLS (Avoid duplicate scan messages after SAAScanComplete)
if 'ScanType' in jsonTest['message']:
del jsonTest['message']['ScanType']
if 'DistanceFromArrivalLS' in jsonTest['message']:
del jsonTest['message']['DistanceFromArrivalLS']
jsonTest['message'].pop('ScanType', None)
jsonTest['message'].pop('DistanceFromArrivalLS', None)

message = simplejson.dumps(jsonTest, sort_keys=True) # Ensure most duplicate messages will get the same key
key = hashlib.sha256(message).hexdigest()
Expand Down

0 comments on commit be7fcc2

Please sign in to comment.