@@ -665,10 +665,9 @@ async def store_async(
665665 )
666666 # Update existing_wiki with current object's attributes if they are not None
667667 updated_wiki = merge_dataclass_entities (
668- source = self ,
669- destination = existing_wiki ,
668+ source = existing_wiki ,
669+ destination = self ,
670670 fields_to_ignore = [
671- "etag" ,
672671 "created_on" ,
673672 "created_by" ,
674673 "modified_on" ,
@@ -762,17 +761,11 @@ async def get_async(
762761 """
763762 if not self .owner_id :
764763 raise ValueError ("Must provide owner_id to get a wiki page." )
764+ if not self .id and not self .title :
765+ raise ValueError ("Must provide id or title to get a wiki page." )
765766
766- # If we have an ID, use it directly (TO SIMPLIFY)
767- elif self .id :
768- wiki_data = await get_wiki_page (
769- owner_id = self .owner_id ,
770- wiki_id = self .id ,
771- wiki_version = self .wiki_version ,
772- synapse_client = synapse_client ,
773- )
774- # If we only have a title, find the wiki page with matching title
775- else :
767+ # If we only have a title, find the wiki page with matching title.
768+ if self .id is None :
776769 async for result in get_wiki_header_tree (
777770 owner_id = self .owner_id ,
778771 synapse_client = synapse_client ,
@@ -785,14 +778,14 @@ async def get_async(
785778
786779 if not matching_header :
787780 raise ValueError (f"No wiki page found with title: { self .title } " )
781+ self .id = matching_header ["id" ]
788782
789- wiki_data = await get_wiki_page (
790- owner_id = self .owner_id ,
791- wiki_id = matching_header ["id" ],
792- wiki_version = self .wiki_version ,
793- synapse_client = synapse_client ,
794- )
795-
783+ wiki_data = await get_wiki_page (
784+ owner_id = self .owner_id ,
785+ wiki_id = self .id ,
786+ wiki_version = self .wiki_version ,
787+ synapse_client = synapse_client ,
788+ )
796789 self .fill_from_dict (wiki_data )
797790 return self
798791
0 commit comments