Search code examples
phpmysqlsocial-networking

How can I deal with deleted photos in an activity stream


In our app, users can upload photographs. This upload event is registered as an activity and pushed into that users 'followers' activity streams.

The flow and tech used is as follows:

  • MYSQL backend for storage (url of uploaded image is stored in photos table along with some metadata)
  • Activity is generated and stored in activities table in MYSQL
  • GEARMAN job is created which sends the activity ID to REDIS where this activity ID is fanned-out to all the users followers in order to populate their activity streams.
  • We retrieve a stream by getting the array of activity ID's from REDIS and then performing a simple IN query in MYSQL.
  • In a users activity stream a small cropped version of the image is visible.

Now this all works fabulously and along with several caching layers has helped keep the system very stable and scaleable.

However, what is considered the best way to deal with a user who chooses to delete one or more of their photos. Currently, when they delete a photo all their followers will get a broken image link in their activity streams.

Therefore we need to choose between two methods of dealing with this.

  1. Store the activity id in the photo table, and delete the activity relating to the photo when a user deletes that photo. This would work nicely but would see a user have activities removed from their streams occasionally.
  2. Flag the image as deleted in the photos table and when generating the stream display a "this image has been deleted by the user" message.

Which would be considered the best approach to take and why? Alternatively are there any other better ways of dealing with this that people would recommend?

Many thanks.


Solution

  • IMO it would be best to make this as transparent as possible. Tell the other users that the image was deleted and offer an option to drop the entry from the activity stream. That way the user stays in control and has no "magick" happening in the background. Maybe for very old entries (what ever this means in current times) you can remove the item automatically. But I would always prefer to get the respective information.