vgrem / Office365-REST-Python-Client

Microsoft 365 & Microsoft Graph Library for Python
MIT License
1.35k stars 336 forks source link

Multiple identical email address returned by event.attendees #622

Open ruuttt opened 1 year ago

ruuttt commented 1 year ago

Thanks you for creating the library. I think I found a bug. Below you can find the steps to reproduce the bug.

When I would create an event using your example code and now would invite two instead of one attendee:

from datetime import datetime, timedelta

from examples import acquire_token_by_username_password
from office365.graph_client import GraphClient
from office365.outlook.calendar.event import Event

client = GraphClient(acquire_token_by_username_password)
new_event = client.me.calendar.events.add()  # type: Event
new_event.subject = "Let's go for lunch"
new_event.body = "Does mid month work for you?"
new_event.start = datetime.utcnow() + timedelta(days=1)
new_event.end = datetime.utcnow() + timedelta(days=1) + timedelta(hours=1)
new_event.attendees = ["fannyd@contoso.onmicrosoft.com", "vvgrem@gmail.com"]
client.execute_query()
print("Event created")

and store the calendar_identifier in a database

events = client.me.calendar.events.get().top(1).select(["subject", "body"]).execute_query()
calendar_identifier = events[0].id
#store calendar_identifier in the database

and when I later on would extract the event like this

#retrieve calendar_identifier from the database
currentEvent=client.me.calendar.events[calendar_identifier ].get().execute_query()

and loop over the attendees, like this

for item in currentEvent.attendees:
    print(item.emailAddress.address)

they all have the same email address, output:

vvgrem@gmail.com
vvgrem@gmail.com

While I would expect this output:

fannyd@contoso.onmicrosoft.com
vvgrem@gmail.com

Versions used:

I would really appreciate it if you would be able to solve this bug in your next release.

vgrem commented 1 year ago

Greetings, thank you for catching this issue 👍 Will look into and get back in the beginning of January

minitriga commented 1 year ago

I'm also hitting the same bug.

michaelmesser commented 4 months ago

I also see this issue. The fix should be easy. The problem is here. This creates one EmailAddress that is shared between all calls to that function. Make the default None and creating the EmailAddress in the function body will fix the issue.

michaelmesser commented 4 months ago

I also notice that the status on attendee is a dictionary rather than an object. I'm using get_calendar_view. .response doesn't work I need result[0].attendees[0].status['response'].