Skip to content

Commit 3db9faa

Browse files
committed
Switch logs to its own collection (Modmail v2.6)
1 parent 426506c commit 3db9faa

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# v2.6.0
8+
9+
Mostly internal changes. Some are slightly breaking. Keep a lookout for broken features and report them on our server.
10+
11+
### Added
12+
- `threads` is now a default alias to `logs`
13+
14+
### Changed
15+
- Log URLs are moved to their own collection.
16+
- Log URLs are now `https://logs.modmail.tk/LOGKEY`, no more numbers before the logkey.
17+
- We still support the numbers so as to not break everyone's urls so quickly but both work atm :p
18+
- 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)
19+
720
# v2.5.2
821

922
Non-Breaking Internal Changes. (This shouldn't affect anyone.)

cogs/modmail.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Modmail:
1818

1919
def __init__(self, bot):
2020
self.bot = bot
21-
21+
2222
def obj(arg):
2323
return discord.Object(int(arg))
2424

@@ -299,7 +299,7 @@ async def nsfw(self, ctx):
299299
await ctx.channel.edit(nsfw=True)
300300
await ctx.message.add_reaction('✅')
301301

302-
@commands.command()
302+
@commands.command(aliases=['threads'])
303303
@commands.has_permissions(manage_messages=True)
304304
@trigger_typing
305305
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
342342
new_day = date.strftime(r'%d %b %Y')
343343
time = date.strftime(r'%H:%M')
344344

345-
key = entry['key']
346-
user_id = entry.get('user_id')
345+
key = entry['_id']
347346
closer = entry['closer']['name']
348-
log_url = f"https://logs.modmail.tk/{user_id}/{key}" if not self.bot.selfhosted else self.bot.config.log_url + f'/logs/{key}'
347+
log_url = f"https://logs.modmail.tk/{key}" if not self.bot.selfhosted else self.bot.config.log_url + f'/logs/{key}'
349348

350349
truncate = lambda c: c[:47].strip() + '...' if len(c) > 50 else c
351350

core/changelog.py

-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,3 @@ async def from_repo(cls, bot, url=None):
6666
if __name__ == '__main__':
6767
with open('../CHANGELOG.md') as f:
6868
changelog = ChangeLog(f.read())
69-
print(changelog.latest_version)

core/clients.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def login(cls, bot):
8787

8888
class ModmailApiClient(ApiClient):
8989

90-
base = 'https://api.modmail.tk'
90+
base = 'http://api.example.com'
9191
metadata = base + '/metadata'
9292
github = base + '/github'
9393
logs = base + '/logs'
@@ -205,7 +205,6 @@ async def get_user_logs(self, user_id):
205205
async def get_log(self, channel_id):
206206
return await self.logs.find_one({'channel_id': str(channel_id)})
207207

208-
209208
async def get_log_url(self, recipient, channel, creator):
210209
key = secrets.token_hex(6)
211210

@@ -232,17 +231,17 @@ async def get_log_url(self, recipient, channel, creator):
232231
},
233232
'closer': None,
234233
'messages': []
235-
})
236-
234+
})
235+
237236
return f'{self.app.config.log_url}/logs/{key}'
238-
237+
239238
async def get_config(self):
240239
conf = await self.db.config.find_one({'bot_id': self.app.user.id})
241240
if conf is None:
242241
await self.db.config.insert_one({'bot_id': self.app.user.id})
243242
return {'bot_id': self.app.user.id}
244243
return conf
245-
244+
246245
async def update_config(self, data):
247246
valid_keys = self.app.config.valid_keys - self.app.config.protected_keys
248247
data = {k: v for k, v in data.items() if k in valid_keys}

core/thread.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ async def _close(self, closer, silent=False, delete_channel=True,
103103
return
104104

105105
if self.bot.selfhosted:
106-
log_url = f'{self.bot.config.log_url}/logs/{log_data["key"]}'
106+
log_url = f'{self.bot.config.log_url}/logs/{log_data["_id"]}'
107107
else:
108108
log_url = f"https://logs.modmail.tk/" \
109-
f"{log_data['user_id']}/{log_data['key']}"
109+
f"{log_data['_id']}"
110110

111111
user = self.recipient.mention if self.recipient else f'`{self.id}`'
112112

@@ -116,7 +116,7 @@ async def _close(self, closer, silent=False, delete_channel=True,
116116
else:
117117
sneak_peak = 'No content'
118118

119-
desc = f"{user} [`{log_data['key']}`]({log_url}): {sneak_peak}"
119+
desc = f"{user} [`{log_data['_id']}`]({log_url}): {sneak_peak}"
120120

121121
em = discord.Embed(description=desc, color=discord.Color.red())
122122

0 commit comments

Comments
 (0)