Skip to main content

January 3

Hi everyone! Happy new year and everything, better have eaten too much chocolate  XD

Got quite a lot to write today, been busy.

Private Messages

Most of my time in the last week or so has been spent implementing private messaging functionality. The backend part of this is done, alongside a bit of the frontend (namely the dropdown notification menu for PMs), but I still need to make the main “messages” page where you can browse your PMs and so on.

The default settings for PMs will be that only people you follow can message you; the settings page for it is done and has four separate settings:

  • Anyone

  • People you follow or who follow you

  • Only people you follow (default)

  • No-one

As with other sites, people who you already have existing conversations with will still be able to message you if you change your settings later.

Logging improvements: email logging

Maintaining the site effectively means having good logging practices. I spent a bit of time figuring out how to get Amazon SES (the email service) to automatically send mails whenever a high priority logging event occurs. Normally this would be fairly simple, but unfortunately Monolog - an otherwise great PHP framework for logging - does not have any easy-to-use email logging support, it requires installing an entire separate framework and a bunch of other stuff.

I’ve got it working with the help of a small package designed to allow PHPMailer (one of the standard ways of sending email from PHP) to work with Monolog, and then configuring PHPMailer to send from Amazon SES. The beautiful result looks like this: https://twitter.com/antsstyle/status/1608202842183016450

Logging improvements: log rotation

Until this point I hadn’t looked into rotating log files (in other words, archiving old logs neatly). Linux’s logrotate tool is a well known great solution for this, so I got it up and running on ArtRetweeter and NFT Crypto Blocker to test it out. It’s sorted now, surprisingly easy to configure.

I’ll need to write a few configuration files, and add some instructions to my server deployment instruction files, but that’s it. It’ll help to debug issues later on instead of having to try and go through gigantic log files, which doesn’t generally end well. In addition, logrotate can be configured compress old log files and delete really old ones - compressed text files tend to have a tiny fraction of their uncompressed file size. This comes with the benefit of not having to worry about checking server log files every so often, since they could actually get big enough to eat up the server’s hard disk space and cause it to be unable to function if left for a very long time.

Improved ID generation

Up to now, artwork IDs were generated by stripping the title of any non-alphanumeric characters, and adding a large random number to the end of it. This was done partially to avoid making scraping artwork on the site too easy (not that it would stop a determined bad actor), but also to avoid duplicated external artwork IDs and still have readable URLs.

I’ve improved this slightly. Instead of using mt_rand to produce a random number, the code now uses the decimal value of the uniqid function, which gives more certainty that there will never be a duplicate value. For most purposes this will never matter, it just covers an awkward edge case of two artists submitting something with the same title and happening to get the same random number (one of their submissions would fail and have to be re-submitted in such a case).

I made this change since I figured that with private messages, there needed to be a similar ID system for message threads. It wouldn’t result in being able to read messages you shouldn’t be able to, as that’s always validated server-side, but it could cause message sending to fail in astronomically unlikely cases.

Maintenance mode

I’ve implemented the “maintenance mode” feature for the site, where I can switch on and off a mode whereby every page redirects to a static ‘maintenance’ page telling people the website is down for maintenance. You can’t just switch the webservers off or something, since people would be greeted with an unpleasant browser error.

This required three things: a version of the main page that has no PHP involved, adding a version of the Apache httpd.conf rules to force all webpage requests to go to the maintenance page, and a shell script to enable or disable maintenance mode. The shell script basically just copies the appropriate httpd.conf into the Apache conf directory, then restarts apache.

This will be useful during planned downtime if/when that occurs; it’ll allow me to tell people when the site is expected to be back up and so forth.

Articles

I’ve started to write some of the articles I want the site to have. There’s a few categories these will fall into:

  • Tech explanations of how the site is built

  • Recommendations of other art sites, print/digital sites, password managers, other useful things

  • Tips for artists about how to use the site, setting commission prices, etc.

There will also be a set of rules on what artist commission TOS pages can’t contain, since I’ve seen some dodgy as hell ones in the past, and it’s not the sort of thing I want to see on the site. That said it’s pretty rare, so it’s not likely to impact many users if any, but I think it's sufficiently important to have.

AWS Region Migration

One of the longstanding decisions I needed to make was which region to host the website and its infrastructure in. AWS has a bunch of different regions, with different costs; basically the choice was between two of the cheapest regions, US East (Ohio) and EU (Ireland).

I’ve decided on Ireland, as the website’s infrastructure being within the EU means that better data protection rules are in place. I had to change a bunch of things on AWS for this work - e.g. making new S3 file buckets, re-creating Lambda functions and all their environment variables in the new region, etc, but it’s done and working now. I also got SES (email service) production access in Ireland, so that’s all good to go.

I’ve also changed the CDN urls from anttests.com (which I used for testing, shouldn’t be needed now; I’ll likely register a different domain for future testing purposes) to desertedchateau.com. One less thing to change when the site launches.