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
784 changes: 784 additions & 0 deletions social_media_linkedin/README.rst

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions social_media_linkedin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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 .hooks import uninstall_hook
31 changes: 31 additions & 0 deletions social_media_linkedin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Social Media Linkedin",
"summary": "Integration of the LinkedIn 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_linkedin/static/src/components/**/*.js",
"social_media_linkedin/static/src/js/services/**/*.js",
"social_media_linkedin/static/src/js/views/**/*.js",
],
},
"installable": True,
}
4 changes: 4 additions & 0 deletions social_media_linkedin/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import social_media_linkedin
66 changes: 66 additions & 0 deletions social_media_linkedin/controllers/social_media_linkedin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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.exceptions import AccessError, UserError
from odoo.http import request, route

_logger = logging.getLogger(__name__)


class SocialMediaLinkedin(http.Controller):
"""Endpoint called by LinkedIn at the end of the OAuth flow."""

@route(
["/linkedin/callback"],
type="http",
auth="user",
)
def social_linkedin(self, access_token=None, code=None, **kwargs):
SocialAccount = request.env["social.account"]
try:
(
client_id,
client_secret,
access_token,
) = SocialAccount._get_access_token_linkedin(
code, request.httprequest.path, kwargs
)
SocialAccount._create_account_linkedin(
client_id, client_secret, access_token
)
SocialAccount._notify_user_session(
SocialAccount._format_user_notification(
_("The account was associated successfully"),
media="linkedin",
message_type="success",
),
message_type="success",
)
return request.redirect(SocialAccount._get_social_dashboard_url())
except (AccessError, UserError) as e:
SocialAccount._consume_linkedin_oauth_wizard(kwargs.get("state", ""))
# These messages are written for the end user and explain what to
# do, so they are the only useful feedback of the association flow.
SocialAccount._notify_user_session(
SocialAccount._format_user_notification(str(e), media="linkedin")
)
_logger.warning("Error in the LinkedIn OAuth callback: %s", e)
return request.redirect("/web")
except Exception: # noqa: BLE001 - the provider may fail in any way
SocialAccount._consume_linkedin_oauth_wizard(kwargs.get("state", ""))
# 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="linkedin",
)
)
_logger.exception("Error in the LinkedIn OAuth callback")
return request.redirect("/web")
17 changes: 17 additions & 0 deletions social_media_linkedin/data/social_media_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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_linkedin" model="social.media">
<field name="name">LinkedIn</field>
<field name="media_type">linkedin</field>
<field
name="description"
>Manage your LinkedIn account and schedule posts</field>
<field
name="image"
type="base64"
file="social_media_linkedin/static/description/icon.png"
/>
</record>
</odoo>
9 changes: 9 additions & 0 deletions social_media_linkedin/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.addons.social_media_base.hooks import remove_social_media


def uninstall_hook(env):
"""Remove the LinkedIn data when the connector is uninstalled."""
remove_social_media(env, "linkedin")
Loading
Loading