Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
38c6e7a6
Commit
38c6e7a6
authored
Jan 27, 2023
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
activity id fixed
parent
86603b3f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
7 deletions
+62
-7
app.py
app.py
+33
-2
messaging_extension_action_preview_bot.py
bots/messaging_extension_action_preview_bot.py
+7
-4
pa_message.py
entities/json/pa_message.py
+1
-0
cosmos_client.py
utils/cosmos_client.py
+21
-1
No files found.
app.py
View file @
38c6e7a6
...
...
@@ -14,9 +14,9 @@ from aiohttp.web_fileresponse import FileResponse
from
botbuilder.core
import
(
BotFrameworkAdapterSettings
,
TurnContext
,
BotFrameworkAdapter
,
BotFrameworkAdapter
,
CardFactory
,
)
from
botbuilder.schema
import
Activity
,
ActivityTypes
from
botbuilder.schema
import
Activity
,
ActivityTypes
,
ResourceResponse
from
marshmallow
import
EXCLUDE
,
ValidationError
from
bots.messaging_extension_action_preview_bot
import
\
...
...
@@ -199,6 +199,37 @@ async def v1_get_health_check(_request: Request) -> Response:
# key = await KEY_VAULT_CLIENT.create_key("pumpalot")
# encrypted_data = await KEY_VAULT_CLIENT.encrypt(key, b"hello")
# decrypted_data = await KEY_VAULT_CLIENT.decrypt(key, encrypted_data)
conversation_reference
=
await
BOT
.
cosmos_client
.
get_conversation
(
"a:1aStwF-2DE5JiwY3D56l6w1tEnb0N13ITGJL3Sj4fwnXwFblV1csv3EOsFEqvqQiKfOCvuaXoKuIpsU47QTnb4Pb_65G89EfgDzzL9EbhTDAi4eq4EG18xQGsjogUhlEo"
,
"d3c0e3f9-060e-43d8-9d64-57fbb51d2003"
)
conversation_reference
.
activity_id
=
'1674824975220'
async
def
cb
(
turn_context
:
TurnContext
):
""" callback """
activity
=
Activity
(
id
=
'1674825125020'
,
type
=
ActivityTypes
.
message
)
activity
.
attachments
=
[
CardFactory
.
adaptive_card
({
"type"
:
"AdaptiveCard"
,
"$schema"
:
"http://adaptivecards.io/schemas/adaptive-card.json"
,
"version"
:
"1.5"
,
"body"
:
[
{
"type"
:
"TextBlock"
,
"text"
:
"The card to be purged2"
,
"wrap"
:
True
}
]
})
]
response
=
await
turn_context
.
update_activity
(
activity
)
print
(
f
"response: {response}"
)
print
(
f
"activity: {activity}"
)
await
ADAPTER
.
continue_conversation
(
conversation_reference
,
cb
,
app_config
.
APP_ID
)
Log
.
i
(
TAG
,
"v1_health_check::ok"
)
return
Response
(
status
=
HTTPStatus
.
OK
,
content_type
=
"application/json"
)
except
Exception
as
e
:
...
...
bots/messaging_extension_action_preview_bot.py
View file @
38c6e7a6
...
...
@@ -121,8 +121,7 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
async
def
callback
(
turn_context
:
TurnContext
)
->
None
:
""" Turn Context callback. Kinda awful syntax, I know """
try
:
activity
=
Activity
(
type
=
ActivityTypes
.
message
,
text
=
"REMOVE ME"
)
activity
=
Activity
(
type
=
ActivityTypes
.
message
)
if
card
is
not
None
and
isinstance
(
card
,
dict
):
# TODO(s1z): handle card!
if
self
.
is_carousel
(
card
):
...
...
@@ -138,8 +137,8 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
# unknown dara type received
Log
.
e
(
TAG
,
"send_message::error:unknown card"
)
response
=
await
turn_context
.
send_activity
(
activity
)
p
rint
(
"RESPONSE:"
,
response
,
"id:"
,
response
.
id
,
"activity:"
,
activity
)
p
a_message
.
message_id
=
response
.
id
await
self
.
cosmos_client
.
create_pa_message
(
pa_message
)
return
future
.
set_result
(
response
)
else
:
# TODO(s1z): add response!!!
...
...
@@ -188,6 +187,10 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
message
=
Activity
(
type
=
ActivityTypes
.
message
,
attachments
=
attachments
)
response
=
await
turn_context
.
send_activity
(
message
)
notification
.
message_id
=
response
.
id
await
self
.
cosmos_client
.
update_notification
(
notification
)
print
(
f
"notification response: {response}"
)
future
.
set_result
(
notification
.
id
)
except
Exception
as
exception
:
...
...
entities/json/pa_message.py
View file @
38c6e7a6
...
...
@@ -14,3 +14,4 @@ class PAMessage(CamelCaseMixin):
tenant_id
:
str
card
:
Optional
[
Any
]
=
None
content_t_t_l
:
Optional
[
ContentTTL
]
=
None
message_id
:
Optional
[
str
]
=
None
utils/cosmos_client.py
View file @
38c6e7a6
...
...
@@ -260,13 +260,23 @@ class CosmosClient:
async
def
create_notification
(
self
,
notification
:
NotificationCosmos
)
\
->
NotificationCosmos
:
""" Crete notification
to
the DB """
""" Crete notification
in
the DB """
notification
.
id
=
uuid
.
uuid4
()
.
__str__
()
schema
=
NotificationCosmos
.
get_schema
(
unknown
=
EXCLUDE
)
container
=
await
self
.
get_notifications_container
()
# TODO(s1z): change this to async!!!
saved_item
=
container
.
create_item
(
body
=
schema
.
dump
(
notification
))
return
schema
.
load
(
saved_item
)
async
def
update_notification
(
self
,
notification
:
NotificationCosmos
)
\
->
NotificationCosmos
:
""" Update notification in the DB """
schema
=
NotificationCosmos
.
get_schema
(
unknown
=
EXCLUDE
)
container
=
await
self
.
get_notifications_container
()
# TODO(s1z): change this to async!!!
saved_item
=
container
.
upsert_item
(
body
=
schema
.
dump
(
notification
))
return
schema
.
load
(
saved_item
)
async
def
create_pa_message
(
self
,
pa_message
:
PAMessage
)
->
PAMessage
:
""" Saves PA Message to DB """
pa_message
.
id
=
uuid
.
uuid4
()
.
__str__
()
...
...
@@ -277,6 +287,16 @@ class CosmosClient:
saved_item
=
container
.
create_item
(
body
=
pa_message_dumped
)
return
schema
.
load
(
saved_item
)
async
def
update_pa_message
(
self
,
pa_message
:
PAMessage
)
->
PAMessage
:
""" Update notification in the DB """
schema
=
PAMessage
.
get_schema
(
unknown
=
EXCLUDE
)
container
=
await
self
.
get_pa_container
()
pa_message_dumped
=
schema
.
dump
(
pa_message
)
print
(
f
"pa_message_dumped: {pa_message_dumped}"
)
saved_item
=
container
.
upsert_item
(
body
=
pa_message_dumped
)
return
schema
.
load
(
saved_item
)
async
def
get_acknowledges_container
(
self
)
->
ContainerProxy
:
""" get_acknowledges_container """
from
config
import
CosmosDBConfig
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment