XF 2.2 Adding PMs and posts externally

We've been working on having our sister site (which is on the same server/domain as our current xenforo boards) auto-post certain things to our Xenforo forum (both PMs and threads). We can successfully have the PMs and thread posts input the data and display the way it needs to, however, there must be a step in there we are missing for the notification part. For PMs, the new message doesn't show the notification icon until after clicking on the message box. For posts, they don't show as the most recent post within that thread, but when you click on that thread, it does show as the most recent post.

If our code is needed, I can provide that as well.
 
That's what I expected ;)

You are not updating fields in other tables correctly (I don't know off head which fields exactly).

Running your own direct DB manipulation magic without knowing XenForo internals 110% is screaming for trouble, especially thinking of future schema / code changes.

It also creates a very tight coupling.

Really, unless absolutely required:
Don't do that and use the API.
 
Fully agree with Kirby. If you do not want to use the API since you want to use integrated code, then you still need to use the XF libraries instead to create the post/conversation entities, initiate alerts etc. But you cannot inject directly into the database since there are that many procedures you are missing out on when you do that.

For example: you inject into xf_user_alert to send an alert. But what about users who opted out of this alert type? It's an endless rabbit hole.
 
If you do not want to use the API since you want to use integrated code, then you still need to use the XF libraries instead to create the post/conversation entities, initiate alerts etc.
Wouldn't work, @notatardis wants to publish content from one XF to another XF (if I understood the question correctly).

It's not really possible to interact with two instances within one request due to Dependency Injection.

Doing this for example from WordPress to XenForo could work.
 
It may be possible to load the XF libraries inside the other installation and then execute the proper XF routines. You can test to see if it doesn't generate any conflicts.

To load XF:
PHP:
$dir = '/path/to/xf';
require ($dir . '/src/XF.php');

XF::start($dir);
$app = XF::setupApp('XF\Pub\App');

If that doesn't generate fatal errors or other issues, then you can proceed with the proper routines to generate PM's.
 
Back
Top Bottom