Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# generated from manifests external_dependencies
odoo_test_helper
requests_oauthlib
requests_toolbelt
tweepy
546 changes: 546 additions & 0 deletions social_media_x/README.rst

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions social_media_x/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from . import controllers
from . import models
from . import wizards

from odoo.addons.social_media_base import remove_social_media


def uninstall_hook(env):
remove_social_media(env, "x")
35 changes: 35 additions & 0 deletions social_media_x/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Social Media X",
"summary": "Integration of the X social media.",
"version": "17.0.1.0.0",
"category": "Social Network",
"development_status": "Beta",
"license": "AGPL-3",
"uninstall_hook": "uninstall_hook",
"author": "BinhexTeam,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"maintainers": ["edescalona"],
"depends": [
"social_media_base",
],
"data": [
"data/social_media_data.xml",
"views/social_account_views.xml",
"wizards/wizard_social_account.xml",
],
"assets": {
"web.assets_backend": [
"social_media_x/static/src/js/views/**/*.js",
],
},
"external_dependencies": {
"python": [
"tweepy",
"requests_oauthlib",
],
},
"installable": True,
}
1 change: 1 addition & 0 deletions social_media_x/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import social_media_x
46 changes: 46 additions & 0 deletions social_media_x/controllers/social_media_x.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo import _, http
from odoo.http import request, route

_logger = logging.getLogger(__name__)


class SocialMediaX(http.Controller):
"""Endpoint called by X to close the OAuth 1.0a flow."""

@route(
["/social_x/callback"],
type="http",
auth="user",
)
def social_x(self, **kwargs):
SocialAccount = request.env["social.account"]
try:
# The request token lives on the wizard, whose credentials are
# restricted to the system group; the wizard is looked up by
# ``oauth_token`` and ``create_uid`` inside ``_get_access_token``.
access_token, access_token_secret = SocialAccount.sudo()._get_access_token(
kwargs
)
if access_token and access_token_secret:
SocialAccount.create_account_x(
access_token, access_token_secret, kwargs
)
except Exception: # noqa: BLE001 - the provider may fail in any way
# The exception may carry the raw provider response, so the user
# only gets a generic message and the detail stays in the log.
SocialAccount._notify_user_session(
SocialAccount._format_user_notification(
_(
"The account could not be associated. "
"Check the server log for details."
),
media="X",
)
)
_logger.exception("Error creating the X account")
return request.redirect(SocialAccount._get_social_dashboard_url())
15 changes: 15 additions & 0 deletions social_media_x/data/social_media_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Binhex <https://www.binhex.cloud>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record id="social_media_x" model="social.media">
<field name="name">X</field>
<field name="media_type">x</field>
<field name="description">Manage your X account and schedule posts</field>
<field
name="image"
type="base64"
file="social_media_x/static/description/icon.png"
/>
</record>
</odoo>
Loading
Loading