Fix crossposts to DeadJournal failing every time, because of unknown
metadata user_agent
Patch by afuna.
diffs (54 lines):
diff -r dd69cca39bad -r b2d3e39c090a cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm Mon May 11 17:47:57 2009 +0000
+++ b/cgi-bin/DW/External/Site.pm Tue May 12 13:09:03 2009 +0000
@@ -53,7 +53,7 @@ sub new {
domain => $domain,
sitename => $sitename,
servicetype => $servicetype
- }
+ }, $class."::".$sitename
}
# returns the appropriate site for this sitename.
@@ -136,5 +136,9 @@ sub badge_image_url {
return 'http://' . $self->{hostname} . '/img/userinfo.gif';
}
+# adjust the request for any per-site limitations
+sub pre_crosspost_hook {
+ return $_[1];
+}
1;
diff -r dd69cca39bad -r b2d3e39c090a cgi-bin/DW/External/Site/DeadJournal.pm
--- a/cgi-bin/DW/External/Site/DeadJournal.pm Mon May 11 17:47:57 2009 +0000
+++ b/cgi-bin/DW/External/Site/DeadJournal.pm Tue May 12 13:09:03 2009 +0000
@@ -73,5 +73,15 @@ sub badge_image_url {
return 'http://www.deadjournal.com/img/userinfo.gif';
}
+# argument: request hash
+# returns: modified request hash
+sub pre_crosspost_hook {
+ my ( $self, $req ) = @_;
+
+ # this causes DeadJournal to choke with an "unknown metadata" error
+ delete $req->{props}->{useragent};
+
+ return $req;
+}
1;
diff -r dd69cca39bad -r b2d3e39c090a
cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm
--- a/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Mon May 11 17:47:57
2009 +0000
+++ b/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Tue May 12 13:09:03
2009 +0000
@@ -215,6 +215,9 @@ sub entry_to_req {
# and set the useragent - FIXME put this somewhere else?
$req->{props}->{useragent} = "Dreamwidth Crossposter";
+
+ # do any per-site preprocessing
+ $req = $extacct->externalsite->pre_crosspost_hook( $req );
return $req;
}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog