LOC-11: Automatic room closure



Issue Information

Issue Type: New Feature
 
Priority: Major
Status: Closed

Reported By:
Ben Tasker
Assigned To:
Ben Tasker
Project: LocalChat (LOC)
Resolution: Done (2018-05-19 13:09:04)
Target version: V0.0.2,
Components: Server ,

Created: 2018-05-13 12:37:45
Time Spent Working


Description
After a defined period of inactivity, a room (and any stored messages, associated users etc) should be purged.

At end of use, a room owner should always use room /close, this feature is intended purely as a safety net for occasions where an owner gets disconnected and cannot reconnect for some reason.

The period should be a reasonable one (6 hours maybe) and should probably be configurable on the server side.


Toggle State Changes

Activity


One thing this does hit up against, is the same question in as LOC-6.

How should we schedule this task? Using a cronjob means an additional setup step (and there's a risk an adversary could quietly delete the cron without anyone noticing). Scheduling within the main process would probably be preferable.
Repo: LocalChat
Host:Rimmer

commit 0968e8506e30342a6cd55c6fc9b5cd13c2aa1578
Author: B Tasker <github@<Domain Hidden>>
Date: Sat May 19 12:45:20 2018 +0100

Commit Message: LOC-11 Add a field to record the last activity in a room

Currently unused by anything, but will be used for the automatic room closure.

Only gets updated when a message is sent by a user. May want to think about whether or not we want to also update when system messages are sent - it probably makes sense to, as it'd be irritating if you joined seconds before the closure threshold and hadn't sent a message yet.

server/LocalChat.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)


View Commit | View Changes
btasker changed status from 'Open' to 'Resolved'
btasker added 'Done' to resolution
btasker changed status from 'Resolved' to 'Closed'
Repo: LocalChat
Host:Rimmer

commit ef39ae2d62e3d8de4bd0132a459e930ead26991e
Author: B Tasker <github@<Domain Hidden>>
Date: Sat May 19 12:49:08 2018 +0100

Commit Message: LOC-11 Update last used time for all message types

We'll now update lastactivity when DMs are sent, or when SYSTEM sends a message.

Should avoid having the room close on you if you join a second before the auto-close would have triggered

server/LocalChat.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)


View Commit | View Changes
Repo: LocalChat
Host:Rimmer

commit faba89833cac58ddc09c0252464b8e89c3bf5b5d
Author: B Tasker <github@<Domain Hidden>>
Date: Sat May 19 13:06:21 2018 +0100

Commit Message: LOC-11 Implementing auto-closure of rooms

If a room has no activity for the configured period (currently 6 hours) it should automatically be closed:

- Any messages are scrubbed
- Any user records are scrubbed
- User sessions purged
- Failure messages removed
- Room record removed

Ran a test with the interval configured to 60 seconds. Created room, posted and left. Stdout output (with a print added) was

        1526731411.929024 Request start
        {u'action': u'schedulerTrigger', u'pass': u'eGET8AfbG9y2BWjDZjg3BoiKuXdyU32CE1dnyJ8FJsuRtxuZ5LvMqoLVIhkQ3gx8'}
        127.0.0.1 - - [19/May/2018 13:03:31] "POST / HTTP/1.1" 200 -
        1526731471.993863 Request start
        {u'action': u'schedulerTrigger', u'pass': u'eGET8AfbG9y2BWjDZjg3BoiKuXdyU32CE1dnyJ8FJsuRtxuZ5LvMqoLVIhkQ3gx8'}
        (1, u'BenTest2')
        127.0.0.1 - - [19/May/2018 13:04:31] "POST / HTTP/1.1" 200 -
        1526731532.039276 Request start
        {u'action': u'schedulerTrigger', u'pass': u'eGET8AfbG9y2BWjDZjg3BoiKuXdyU32CE1dnyJ8FJsuRtxuZ5LvMqoLVIhkQ3gx8'}
        127.0.0.1 - - [19/May/2018 13:05:32] "POST / HTTP/1.1" 200 -
    


So I'm happy the purge is running.

This absolutely should not be relied on as an alternative to running /room close [pass] though. It's meant as a safety net and nothing more.

server/LocalChat.py | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)


View Commit | View Changes
Repo: LocalChat
Host:Rimmer

commit f58f63457157fa893bc862923dbb731c64ee0ad6
Author: B Tasker <github@<Domain Hidden>>
Date: Mon May 21 00:37:36 2018 +0100

Commit Message: LOC-11 Verify that Automated Room closure is functioning

tests/run_tests.py | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 157 insertions(+), 1 deletions(-)


View Commit | View Changes