diff --git a/src/tasks.rs b/src/tasks.rs index 4a431e0..79df7de 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -1119,11 +1119,19 @@ impl TasksRelay { Some(id) } + /// Create the task only incorporating context fn make_task_unchecked( &mut self, input: &str, tags: Vec, ) -> EventId { + let assignee = + if tags.iter().any(|t| t.kind() == TagKind::p()) { + None + } else { + self.pubkey + .map(|p| Tag::public_key(p)) + }; let prio = if tags.iter().any(|t| t.kind().to_string() == PRIO) { None @@ -1134,7 +1142,8 @@ impl TasksRelay { EventBuilder::new(TASK_KIND, input) .tags(self.context_hashtags()) .tags(tags) - .tags(prio), + .tags(prio) + .tags(assignee), ) } diff --git a/src/tasks/tests.rs b/src/tasks/tests.rs index 9633e68..cf60989 100644 --- a/src/tasks/tests.rs +++ b/src/tasks/tests.rs @@ -149,7 +149,16 @@ fn test_context() { // s2-4 are newest while s2,s3,hp are highest prio assert_tasks_visible!(tasks, [s4, s2, s3, anid, id_hp]); - tasks.pubkey = Some(Keys::generate().public_key); + let hoi = tasks.make_task("hoi").unwrap(); + assert_eq!(tasks.get_by_id(&hoi).unwrap().get_owner(), tasks.sender.pubkey()); + let pubkey = Keys::generate().public_key; + let test1id = tasks.make_task(&("test1 @".to_string() + &pubkey.to_string())).unwrap(); + let test1 = tasks.get_by_id(&test1id).unwrap(); + assert_eq!(test1.get_owner(), pubkey); + tasks.pubkey = Some(pubkey); + let test2id = tasks.make_task("test2").unwrap(); + let test2 = tasks.get_by_id(&test2id).unwrap(); + assert_eq!(test2.get_owner(), pubkey); } #[test]