summary refs log tree commit diff
path: root/scripts/make_identicons.pl
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
committerErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
commit119e5d7702a1de0b196a374b53b646c06ee753e5 (patch)
treea617bb7f11b100e1b6fdbb92c462109950d64908 /scripts/make_identicons.pl
parentMerge pull request #138 from matrix-org/erikj/SYN-371 (diff)
downloadsynapse-119e5d7702a1de0b196a374b53b646c06ee753e5.tar.xz
Seperate scripts/ into scripts/ and scripts-dev/, where scripts/* are automatically added to the package
Diffstat (limited to 'scripts/make_identicons.pl')
-rwxr-xr-xscripts/make_identicons.pl39
1 files changed, 0 insertions, 39 deletions
diff --git a/scripts/make_identicons.pl b/scripts/make_identicons.pl
deleted file mode 100755
index cbff63e298..0000000000
--- a/scripts/make_identicons.pl
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-use DBI;
-use DBD::SQLite;
-use JSON;
-use Getopt::Long;
-
-my $db; # = "homeserver.db";
-my $server = "http://localhost:8008";
-my $size = 320;
-
-GetOptions("db|d=s",     \$db,
-           "server|s=s", \$server,
-           "width|w=i",  \$size) or usage();
-
-usage() unless $db;
-
-my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","") || die $DBI::errstr;
-
-my $res = $dbh->selectall_arrayref("select token, name from access_tokens, users where access_tokens.user_id = users.id group by user_id") || die $DBI::errstr;
-
-foreach (@$res) {
-    my ($token, $mxid) = ($_->[0], $_->[1]);
-    my ($user_id) = ($mxid =~ m/@(.*):/);
-    my ($url) = $dbh->selectrow_array("select avatar_url from profiles where user_id=?", undef, $user_id);
-    if (!$url || $url =~ /#auto$/) {
-        `curl -s -o tmp.png "$server/_matrix/media/v1/identicon?name=${mxid}&width=$size&height=$size"`;
-        my $json = `curl -s -X POST -H "Content-Type: image/png" -T "tmp.png" $server/_matrix/media/v1/upload?access_token=$token`;
-        my $content_uri = from_json($json)->{content_uri};
-        `curl -X PUT -H "Content-Type: application/json" --data '{ "avatar_url": "${content_uri}#auto"}' $server/_matrix/client/api/v1/profile/${mxid}/avatar_url?access_token=$token`;
-    }
-}
-
-sub usage {
-    die "usage: ./make-identicons.pl\n\t-d database [e.g. homeserver.db]\n\t-s homeserver (default: http://localhost:8008)\n\t-w identicon size in pixels (default 320)";
-}
\ No newline at end of file