recipient pubkey is not set when loading in an encrypted DM from_event()
dtdannen opened this issue · comments
Dustin Dannenhauer commented
If I want to create an encrypted DM object from a kind 4 event, the recipient key isn't set anywhere automatically in the encrypted_dm.py file.
Perhaps adding the following to the from_event() method is a solution?
try: # could avoid this with a few checks, this is a lazy solution
if event_msg.event.tags[0][0] == 'p':
dm.recipient_pubkey = event_msg.event.tags[0][1]
except:
pass
to
@classmethod
def from_event(cls, event: Event) -> 'EncryptedDirectMessage':
if event.kind != EventKind.ENCRYPTED_DIRECT_MESSAGE:
return None
dm = EncryptedDirectMessage(encrypted_message=event.content)
dm.pubkey = event.pubkey
dm.event = event
# added code here
try: # could avoid this with a few checks, this is a lazy solution
if event_msg.event.tags[0][0] == 'p':
dm.recipient_pubkey = event_msg.event.tags[0][1]
except:
pass
return dm