Skip to content

Commit 3320688

Browse files
committed
[MIG] mail_gategay_telegram: Migration to v17
WIP for test workflows of mail_gateway migration in #1614
1 parent 180c577 commit 3320688

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

mail_gateway_telegram/__manifest__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"name": "Mail Telegram Gateway",
66
"summary": """
77
Set a gateway for telegram""",
8-
"version": "16.0.1.0.1",
8+
"version": "17.0.1.0.1",
99
"license": "AGPL-3",
1010
"author": "Creu Blanca,Dixmit,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/social",
1212
"depends": ["mail_gateway"],
1313
"data": ["views/mail_gateway.xml"],
1414
"external_dependencies": {"python": ["python-telegram-bot", "lottie", "cairosvg"]},
1515
"assets": {
16-
"mail.assets_messaging": [
17-
"mail_gateway_telegram/static/src/models/**/*.js",
18-
"mail_gateway_telegram/static/src/components/**/*.xml",
19-
],
16+
# "mail.assets_messaging": [
17+
# "mail_gateway_telegram/static/src/models/**/*.js",
18+
# "mail_gateway_telegram/static/src/components/**/*.xml",
19+
# ],
2020
},
2121
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import mail_gateway_channel
1+
from . import discuss_channel
22
from . import mail_gateway
33
from . import mail_gateway_telegram

mail_gateway_telegram/models/mail_gateway_channel.py renamed to mail_gateway_telegram/models/discuss_channel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from odoo.addons.base.models.avatar_mixin import get_hsl_from_seed
88

99

10-
class MailChannel(models.Model):
11-
_inherit = "mail.channel"
10+
class DiscussChannel(models.Model):
11+
_inherit = "discuss.channel"
1212

1313
def _generate_avatar_gateway(self):
1414
if self.gateway_id.gateway_type == "telegram":

mail_gateway_telegram/models/mail_gateway_telegram.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def _get_telegram_attachment_name(self, attachment):
130130
async def _process_telegram_attachment(self, attachment):
131131
if isinstance(attachment, tuple):
132132
attachment = attachment[-1]
133-
# That might happen with images, we will get the last one as it is the bigger one.
133+
# That might happen with images, we will get the last one as it is the
134+
# bigger one.
134135
if isinstance(
135136
attachment,
136137
(
@@ -204,7 +205,13 @@ def _process_update(self, chat, update):
204205
attachments.append(attachment_data)
205206
if len(body) > 0 or attachments:
206207
author = self._get_author(chat.gateway_id, update)
207-
new_message = chat.message_post(
208+
# import wdb; wdb.set_trace()
209+
if author._name == "mail.guest":
210+
chat = chat.with_user(self.env.ref("base.public_user").id).with_context(
211+
guest=author
212+
)
213+
# TODO: Check the sudo...
214+
new_message = chat.sudo().message_post(
208215
body=body,
209216
author_id=author._name == "res.partner" and author.id,
210217
gateway_type="telegram",

mail_gateway_telegram/views/mail_gateway.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
<field name="has_new_channel_security" position="after">
1313
<field
1414
name="telegram_security_key"
15-
attrs="{'invisible': ['|', ('gateway_type', '!=', 'telegram'), ('has_new_channel_security', '=', False)], 'required': [('gateway_type', '=', 'telegram'), ('has_new_channel_security', '=', True)]}"
15+
invisible="gateway_type != 'telegram' or not has_new_channel_security"
16+
required="gateway_type == 'telegram' and has_new_channel_security"
1617
/>
1718
</field>
1819
<notebook position="inside">
1920
<page
2021
name="telegram"
2122
string="Telegram configuration"
22-
attrs="{'invisible': [('gateway_type', '!=', 'telegram')]}"
23+
invisible="gateway_type != 'telegram'"
2324
>
2425
<div>
2526
<ol>

0 commit comments

Comments
 (0)