fix: fix missing else condition to populate user info for non-repo events

This commit is contained in:
Andrii V 2025-03-27 18:33:11 +01:00
parent eecd72acf1
commit 773cf77091
3 changed files with 12 additions and 12 deletions

View file

@ -82,8 +82,10 @@ class RhodecodeEvent(object):
log.debug("Got integration actor: %s", auth_user)
if isinstance(auth_user, AuthUser):
instance = auth_user.get_instance()
# we can't find this DB user...
if not instance:
if instance:
return instance
else:
# we can't find this DB user...
return AttributeDict(
dict(
username=auth_user.username,

View file

@ -17,7 +17,7 @@
# and proprietary license terms, please see https://rhodecode.com/licenses/
import re
import textwrap
import dataclasses
from dataclasses import dataclass, asdict
import logging
from mako.template import Template
@ -28,13 +28,16 @@ from rhodecode.integrations.types.base import CommitParsingDataHandler, render_w
log = logging.getLogger(__name__)
@dataclasses.dataclass
@dataclass
class SlackData:
title: str
text: str
fields: list[dict] | None = None
overrides: dict | None = None
def asdict(self):
return asdict(self)
def html_to_slack_links(message):
return re.compile(r'<a .*?href=["\'](.+?)".*?>(.+?)</a>').sub(r"<\1|\2>", message)

View file

@ -134,15 +134,10 @@ class SlackIntegrationType(IntegrationTypeBase):
handler = SlackDataHandler()
slack_data = handler(event, data)
# convert to dict so
slack_data_dict = {
"title": slack_data.title,
"text": slack_data.text,
"fields": slack_data.fields,
"overrides": slack_data.overrides
}
# Transform to dict so its serializable
slack_data = slack_data.asdict()
# title, text, fields, overrides
run_task(post_text_to_slack, self.settings, slack_data_dict)
run_task(post_text_to_slack, self.settings, slack_data)
@async_task(ignore_result=True, base=RequestContextTask)