Commit d1f3ed08 by Oleksandr Barabash

update to save team_aad_id on conv_update and on_message into…

update to save team_aad_id on conv_update and on_message into reference.conversation.aad_object_id. it's a hack and has to be changed. This value has to be stored in to its own DB
parent 4e464fe2
......@@ -305,16 +305,18 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
async def on_conversation_update_activity(self, turn_context: TurnContext):
""" On update conversation """
i18n = get_i18n(turn_context)
await self.cosmos_client.create_conversation_reference(turn_context)
aad_group_id = None
if turn_context.activity.channel_id == Channels.ms_teams:
team_details = await TeamsInfo.get_team_details(turn_context)
aad_group_id = team_details.aad_group_id
await self.cosmos_client.create_conversation_reference(turn_context,
aad_group_id)
await turn_context.send_activity(
str(turn_context.activity.conversation)
)
if turn_context.activity.channel_id == Channels.ms_teams:
team_details = await TeamsInfo.get_team_details(turn_context)
await turn_context.send_activity(
f"What is this ????: {team_details.aad_group_id}"
)
if turn_context.activity.members_removed:
# members were removed!
......@@ -393,16 +395,14 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
await turn_context.send_activity(i18n.t("tenant_forbidden"))
return
aad_group_id = None
if turn_context.activity.channel_id == Channels.ms_teams:
team_details = await TeamsInfo.get_team_details(turn_context)
await turn_context.send_activity(
f"What is this ????: {team_details.aad_group_id}"
)
aad_group_id = team_details.aad_group_id
# save conversation reference
reference = await self.cosmos_client.create_conversation_reference(
turn_context
turn_context, aad_group_id
)
logger.info(f"TURN_CONTEXT:{turn_context}")
logger.info(f"ACTIVITY:{turn_context.activity}")
......
......@@ -397,14 +397,19 @@ class CosmosClient:
AppConfig.TENANT_ID)
return NotificationCosmos.get_schema(unknown=EXCLUDE).load(item)
async def create_conversation_reference(self, turn_context: TurnContext)\
-> Dict[str, Any]:
async def create_conversation_reference(
self, turn_context: TurnContext,
aad_group_id: Optional[str] = None
) -> Dict[str, Any]:
""" Save Conversation Reference """
from config import CosmosDBConfig
Log.i(__name__, "create_conversation_reference")
activity = turn_context.activity
reference = TurnContext.get_conversation_reference(activity)
if reference.conversation.aad_object_id is None:
# this is a hack, has to be stored in apart of reference
reference.conversation.aad_object_id = aad_group_id
reference_json = ConversationReference.get_schema().dump(reference)
container = await self.get_conversations_container()
reference_json.update({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment