Skip to content

feat: share todo with email #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

jeffstedt
Copy link
Owner

@jeffstedt jeffstedt commented Apr 9, 2025

Added POST /api/todos/:id/share endpoint that will allow one to share a todo with one or many people over email.

Edit: Secretly testing Copilot 👀

@jeffstedt jeffstedt requested a review from Copilot April 9, 2025 14:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • .env: Language not supported

Comment on lines +47 to +49
Deno.test("POST /api/todos/share shares a todo with a user", async () => {
const shareData = { todoId: 1, userId: 2 };
const response = await mockRequest("POST", "http://localhost:8080/api/todos/share", shareData);
Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test URL for sharing a todo is missing the required todo id parameter as per the endpoint '/api/todos/:id/share'. Please update the URL to include an id, for example, '/api/todos/1/share'.

Suggested change
Deno.test("POST /api/todos/share shares a todo with a user", async () => {
const shareData = { todoId: 1, userId: 2 };
const response = await mockRequest("POST", "http://localhost:8080/api/todos/share", shareData);
Deno.test("POST /api/todos/:id/share shares a todo with a user", async () => {
const shareData = { todoId: 1, userId: 2 };
const response = await mockRequest("POST", "http://localhost:8080/api/todos/1/share", shareData);

Copilot uses AI. Check for mistakes.

Comment on lines +43 to +44
// Important: Check that todo hasn't been shared with the same user

Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deduplication check for shared recipients mentioned in the comment is not implemented. Consider adding logic to prevent sharing the same todo with duplicate email addresses.

Suggested change
// Important: Check that todo hasn't been shared with the same user
// Important: Check that todo hasn't been shared with the same user
const deduplicatedSharedWith = Array.from(new Set(validatedBody.sharedWith));

Copilot uses AI. Check for mistakes.

@@ -27,6 +27,7 @@ deno run test
- GET /api/todos - Retrieves all todos.
- GET /api/todos/:id - Retrieves a specific todo by ID.
- POST /api/todos - Creates a new todo
- POST /api/todos/:id/shar - Shares an existing todo
Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The share endpoint path appears to be misspelled as '/shar'. Please correct it to '/share' to match the implementation.

Suggested change
- POST /api/todos/:id/shar - Shares an existing todo
- POST /api/todos/:id/share - Shares an existing todo

Copilot uses AI. Check for mistakes.

Comment on lines +69 to +71
updatedAt: new Date().toISOString(),
sharedWith: inputTodo.sharedWith ?? ["[email protected]"],
};
Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hardcoded default email value is used when sharedWith is not provided. Consider removing or parameterizing this default to avoid unexpected behavior in production.

Suggested change
updatedAt: new Date().toISOString(),
sharedWith: inputTodo.sharedWith ?? ["[email protected]"],
};
updatedAt: new Date().toISOString()
};
if (inputTodo.sharedWith) {
this.todos[inputId].sharedWith = inputTodo.sharedWith;
}

Copilot uses AI. Check for mistakes.

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.

1 participant