-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storage promotion/demotion and legacy object unpinning for entity state API #700
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3089bd9
Add promotion checks with "save_entity_state" route
31fe43f
Handle public link entity states
2637c98
Remove accidental duplicates
c9f7a33
Formatting fix
705db39
Unit tests and prevent broadcast on failed promotion
b2f1423
Move private functions, fix test typo,
f913669
JSON EOF formatting
6735bce
Use maybe_promote_file pattern to avoid promoting and broadcasting in…
a6226f1
Fix inconsistency in shape of maybe_promote_file return and remove un…
3e1cf7d
Set file inactive on unpin
f2029ae
Single delete entity clause, tests to ensure error response
f16b5fb
Error when not authorized and not owned file, unit tests
1ee31ea
Return `file_not_found` if trying to activate non existant owned file
johnshaughnessy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/support/utils/save_entity_state_payload_promotable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"nid": "hvpg97x", | ||
"create_message": { | ||
"version": 1, | ||
"networkId": "hvpg97x", | ||
"prefabName": "media", | ||
"initialData": { | ||
"src": "https://hubs.local:4000/files/101ac987-61f4-4645-b512-def3f0336fdf.jpg?token=2bbfa5ff552a159cff50b8bc212a477c", | ||
"recenter": true, | ||
"resize": true, | ||
"animateLoad": true, | ||
"fileId": "101ac987-61f4-4645-b512-def3f0336fdf", | ||
"isObjectMenuTarget": true | ||
} | ||
}, | ||
"updates": [ | ||
{ | ||
"root_nid": "hvpg97x", | ||
"nid": "hvpg97x", | ||
"update_message": { | ||
"nid": "hvpg97x", | ||
"lastOwnerTime": 1157850816, | ||
"timestamp": 1157852116, | ||
"owner": "9eac3551-20d7-4b04-80fc-2009b5e8fe10", | ||
"data": { | ||
"networked-transform": { | ||
"version": 1, | ||
"data": { | ||
"position": [ | ||
44.335304260253906, | ||
1.4967195987701416, | ||
-6.183996677398682 | ||
], | ||
"rotation": [ | ||
-0.03446304053068161, | ||
0.6161360144615173, | ||
0.026999054476618767, | ||
0.7864221334457397 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"file_id": "101ac987-61f4-4645-b512-def3f0336fdf", | ||
"file_access_token": "2bbfa5ff552a159cff50b8bc212a477c", | ||
"promotion_token": "1701f2fc68081168c7b19ebfabc76dc6" | ||
} |
54 changes: 54 additions & 0 deletions
54
test/support/utils/save_entity_state_payload_unpromotable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"nid": "hvpg97x", | ||
"create_message": { | ||
"version": 1, | ||
"networkId": "hvpg97x", | ||
"prefabName": "media", | ||
"initialData": { | ||
"src": "https://hubs.local:4000/files/101ac987-61f4-4645-b512-def3f0336fdf.jpg?token=2bbfa5ff552a159cff50b8bc212a477c", | ||
"recenter": true, | ||
"resize": true, | ||
"animateLoad": true, | ||
"fileId": "101ac987-61f4-4645-b512-def3f0336fdf", | ||
"isObjectMenuTarget": true | ||
} | ||
}, | ||
"updates": [ | ||
{ | ||
"root_nid": "hvpg97x", | ||
"nid": "hvpg97x", | ||
"update_message": { | ||
"nid": "hvpg97x", | ||
"lastOwnerTime": 1157792473, | ||
"timestamp": 1157845450, | ||
"owner": "9eac3551-20d7-4b04-80fc-2009b5e8fe10", | ||
"data": { | ||
"networked-transform": { | ||
"version": 1, | ||
"data": { | ||
"position": [ | ||
44.30113220214844, | ||
1.4787851572036743, | ||
-5.9799041748046875 | ||
], | ||
"rotation": [ | ||
-0.032501693814992905, | ||
0.6693336963653564, | ||
0.029331713914871216, | ||
0.7416709065437317 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"file_id": "101ac987-61f4-4645-b512-def3f0336fdf", | ||
"promotion_token": "1701f2fc68081168c7b19ebfabc76dc6", | ||
"file_access_token": "dasfaisodfjoein0ewoINCORRECT" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler (and the following one) looks suspicious.
If for some reason the
delete_entity_state
request does not result in the entity state being deleted (and the associatedOwnedFile
becoming inactive), this function shouldreply_error
with a reason. The reasons we should catch are:delete_entity
fails (e.g. the entity doesn't exist),OwnedFile
doesn't existAlso, I think we need to handle the
RoomObject
records slightly differently.On the client, when we load the legacy room objects, we synthesize messages for them so that the client can act as if they are entity create/update messages. (See
loadLegacyRoomObjects
andmessageForLegacyRoomObject
in the client.)We would like to add to this flow a step where a client, when it synthesizes this message, also calls
save_entity_state
so that that data is migrated to the new EntityState storage (non destructively).Therefore, when reticulum receives an
delete_entity_state
directive, there are two (valid) states we should be concerned with:EntityState
and aRoomObject
for thisnid
. We need to delete both.EntityState
for thisnid
. We only need to delete the entity state.Deleting a non-existant RoomObject is probably no trouble, so trying to delete both each time is probably a fine strategy (knowing that many times, the
RoomObject
won't exist).And, as you have done here -- if there is a
file_id
in the payload, we need to mark the associatedOwnedFile
asinactive
. To avoid duplicating code, might consider having a singlehandle_in("delete_entity_state", %{"nid" => nid } = payload ...
, and ifpayload
has afile_id
, callset_inactive
. But that's more a matter of style, not correctness.