I have very superficial knowledge of ActivityPub.
From what I understand, the outbox you mention would be the outbox of a Repository or a Project Actor and the Activity would be the changeset added to the Repository. Is that right ?
I also assume that parameter to addActivity() would be a json-ld structure returned by buildPayloadFromDiff().
Hence in buildPayloadFromDiff you could write something along the lines of:
import rdflib # make sure the rdflib jsonld plugin is installed https://github.com/RDFLib/rdflib-jsonld
from rdflib import RDF, RDFS, DC, URIRef, Literal
DCS = rdflib.Namespace("http://ontologi.es/doap-changeset#")
FEDE = rdflib.Namespace("https://fedeproxy.eu/onto/")
def buildPayloadFromDiff(changeset):
g = rdflib.Graph()
uid = URIRef(changeset.uid)
g.add( (uid, RDF.type, DCS.Changeset) )
g.add( (uid, FEDE.has_text_diff, Literal(changeset.patchdiff))
g.add( (uid, RDFS.label, Literal(changeset.message.lines[0]))
g.add( (uid, RDFS.comment, Literal(changeset.message))
g.add( (uid, DC.creator, URIRef(changeset.author) )
g.add( (uid, DC.date, Literal(changeset.date) )
return g.serialize(format='json-ld')
Of course it is only a sketch and there is a lot to do, but hopefully you get the general idea.