Skip to content
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

More admin #656

Merged
merged 3 commits into from
Aug 25, 2024
Merged

More admin #656

merged 3 commits into from
Aug 25, 2024

Conversation

jp-bennett
Copy link
Contributor

No description provided.

@jp-bennett jp-bennett changed the base branch from master to 2.5 August 24, 2024 22:30
@ianmcorvidae
Copy link
Contributor

This seems pretty good. I'm thinking it might be good if we put the requestConfig calls into the various functions in node.py (setOwner, to use your example), just because it doesn't really make sense to call those functions without also getting a session key. In there, it'd also be easier to wrap it in an if that doesn't bother fetching a session key if one is already present, and it could all get split out into a helper.

tl;dr in node.py maybe something like:

    def ensureSessionKey(self):
        if isinstance(self.nodeNum, int):
            nodeid = self.nodeNum
        elif self.nodeNum.startswith("!"):
            nodeid = int(self.nodeNum[1:],16)
        if self.iface._getOrCreateByNum(nodeid).get("adminSessionPassKey") is None:
            self.requestConfig(admin_pb2.AdminMessage.SESSIONKEY_CONFIG)

and then within setOwner (and whatever else), just throw in a self.ensureSessionKey().

I guess it's a little more awkward within that function (probably we should make a utility function that takes whatever format of nodeid and spits out the integer, for one) but it should mean only writing that logic once, at least.

@jp-bennett jp-bennett marked this pull request as ready for review August 25, 2024 03:25
@ianmcorvidae
Copy link
Contributor

I think this looks good so I'll merge it. I think there might be a couple missing spots for ensureSessionKey calls but I can go through those more quickly in vim than I can on GitHub anyway 😆

@ianmcorvidae ianmcorvidae merged commit 5a06888 into 2.5 Aug 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants