fix: fix missing else condition to populate user info for non-repo events
This commit is contained in:
parent
eecd72acf1
commit
773cf77091
3 changed files with 12 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue