IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit c1ab22e9 authored by Emi Simpson's avatar Emi Simpson
Browse files

Add mattermost support

parent 9ac0569f
Pipeline #267 failed with stages
in 1 minute and 28 seconds
......@@ -230,6 +230,33 @@ class WebsiteLink(Source):
else:
return None
class Mattermost(Source):
URL_REGEX = re.compile(r'(?:https?://[\w\.\-]+.[\w]+/([a-z\-]+)/channels/([a-z\-]+)/?)|(?:https?://[\w.-]+.[\w]+/? ([a-z\d]{26}))')
@staticmethod
def display_name() -> str:
return 'Mattermost Channel'
def validate_source(self) -> Optional[str]:
if Mattermost.URL_REGEX.match(self.url) is None:
return 'Mattermost instances must be a formatted like https://my-mattermost.com/SOME_TEAM/channels/SOME_CHANNEL'
else:
return None
def get_simplified_form(self) -> str:
"""
Returns just the ID of the channel, or team/name
"""
match = Mattermost.URL_REGEX.match(self.url)
assert match is not None, "get_simplified_form should only be called on valid sources"
team = match.group(1)
channel = match.group(2)
chan_id = match.group(3)
if team is not None:
return f'{team}/{channel}'
else:
return chan_id
SOURCE_PROCESSORS: Dict[str, Type[Source]] = {
'git': Git,
'github': GitHub,
......@@ -237,6 +264,7 @@ SOURCE_PROCESSORS: Dict[str, Type[Source]] = {
'rss': Rss,
'osf': Osf,
'web': WebsiteLink,
'mattermost': Mattermost,
#TODO Add more sources (https://github.com/chaoss/grimoirelab-sirmordred#supported-data-sources-)
}
"""
......
......@@ -130,6 +130,11 @@ sleep-time = 300
raw_index = rss_raw
enriched_index = rss_enriched
#[mattermost]
#api-token = <YOUR_API_TOKEN_HERE>
#raw_index = mattermost_raw
#enriched_index = mattermost_enriched
## studies based on enriched indexes
[enrich_demography:git]
......
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