diff --git a/CHANGELOG.md b/CHANGELOG.md index db993fb075..8c75c20242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# v2.6.0 + +Mostly internal changes. Some are slightly breaking. Keep a lookout for broken features and report them on our server. + +### Added +- `threads` is now a default alias to `logs` + +### Changed +- Log URLs are moved to their own collection. +- Log URLs are now `https://logs.modmail.tk/LOGKEY`, no more numbers before the logkey. +- We still support the numbers so as to not break everyone's urls so quickly but both work atm :p +- This is a huge change to the backend logging and there might be migration errors. If so, please contact us at our [discord server](https://discord.gg/2fMbf2N) + # v2.5.2 Non-Breaking Internal Changes. (This shouldn't affect anyone.) diff --git a/cogs/modmail.py b/cogs/modmail.py index 56aa90aeff..7f49b0e860 100644 --- a/cogs/modmail.py +++ b/cogs/modmail.py @@ -18,7 +18,7 @@ class Modmail: def __init__(self, bot): self.bot = bot - + def obj(arg): return discord.Object(int(arg)) @@ -299,7 +299,7 @@ async def nsfw(self, ctx): await ctx.channel.edit(nsfw=True) await ctx.message.add_reaction('✅') - @commands.command() + @commands.command(aliases=['threads']) @commands.has_permissions(manage_messages=True) @trigger_typing async def logs(self, ctx, *, member: Union[discord.Member, discord.User, obj]=None): @@ -342,10 +342,9 @@ async def logs(self, ctx, *, member: Union[discord.Member, discord.User, obj]=No new_day = date.strftime(r'%d %b %Y') time = date.strftime(r'%H:%M') - key = entry['key'] - user_id = entry.get('user_id') + key = entry['_id'] closer = entry['closer']['name'] - log_url = f"https://logs.modmail.tk/{user_id}/{key}" if not self.bot.selfhosted else self.bot.config.log_url + f'/logs/{key}' + log_url = f"https://logs.modmail.tk/{key}" if not self.bot.selfhosted else self.bot.config.log_url + f'/logs/{key}' truncate = lambda c: c[:47].strip() + '...' if len(c) > 50 else c diff --git a/core/changelog.py b/core/changelog.py index a5b8378b44..3c921c6710 100644 --- a/core/changelog.py +++ b/core/changelog.py @@ -66,4 +66,3 @@ async def from_repo(cls, bot, url=None): if __name__ == '__main__': with open('../CHANGELOG.md') as f: changelog = ChangeLog(f.read()) - print(changelog.latest_version) diff --git a/core/clients.py b/core/clients.py index d5cb1341ed..d359811c70 100644 --- a/core/clients.py +++ b/core/clients.py @@ -87,7 +87,7 @@ async def login(cls, bot): class ModmailApiClient(ApiClient): - base = 'https://api.modmail.tk' + base = 'http://api.example.com' metadata = base + '/metadata' github = base + '/github' logs = base + '/logs' @@ -205,7 +205,6 @@ async def get_user_logs(self, user_id): async def get_log(self, channel_id): return await self.logs.find_one({'channel_id': str(channel_id)}) - async def get_log_url(self, recipient, channel, creator): key = secrets.token_hex(6) @@ -232,17 +231,17 @@ async def get_log_url(self, recipient, channel, creator): }, 'closer': None, 'messages': [] - }) - + }) + return f'{self.app.config.log_url}/logs/{key}' - + async def get_config(self): conf = await self.db.config.find_one({'bot_id': self.app.user.id}) if conf is None: await self.db.config.insert_one({'bot_id': self.app.user.id}) return {'bot_id': self.app.user.id} return conf - + async def update_config(self, data): valid_keys = self.app.config.valid_keys - self.app.config.protected_keys data = {k: v for k, v in data.items() if k in valid_keys} diff --git a/core/thread.py b/core/thread.py index 3d928a78e3..01bca7a2f3 100644 --- a/core/thread.py +++ b/core/thread.py @@ -103,10 +103,10 @@ async def _close(self, closer, silent=False, delete_channel=True, return if self.bot.selfhosted: - log_url = f'{self.bot.config.log_url}/logs/{log_data["key"]}' + log_url = f'{self.bot.config.log_url}/logs/{log_data["_id"]}' else: log_url = f"https://logs.modmail.tk/" \ - f"{log_data['user_id']}/{log_data['key']}" + f"{log_data['_id']}" user = self.recipient.mention if self.recipient else f'`{self.id}`' @@ -116,7 +116,7 @@ async def _close(self, closer, silent=False, delete_channel=True, else: sneak_peak = 'No content' - desc = f"{user} [`{log_data['key']}`]({log_url}): {sneak_peak}" + desc = f"{user} [`{log_data['_id']}`]({log_url}): {sneak_peak}" em = discord.Embed(description=desc, color=discord.Color.red())