Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
c2f2f325
Commit
c2f2f325
authored
Nov 14, 2014
by
Dave Cridland
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #103 from akrherz/of324
OF-324 Offline Email Notification Plugin
parents
b724b3fa
34e2a999
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
0 deletions
+141
-0
plugin.xml
src/plugins/emailOnAway/plugin.xml
+13
-0
emailOnAway.java
...lugins/emailOnAway/src/java/com/tempstop/emailOnAway.java
+128
-0
No files found.
src/plugins/emailOnAway/plugin.xml
0 → 100644
View file @
c2f2f325
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<!-- Main plugin class -->
<class>
com.tempstop.emailOnAway
</class>
<name>
Email on Away
</name>
<description>
Messages sent to alternate location when recipient is away
</description>
<author>
Nick Mossie
</author>
<version>
1.0
</version>
<date>
12/15/2005
</date>
<minServerVersion>
2.3.0
</minServerVersion>
</plugin>
src/plugins/emailOnAway/src/java/com/tempstop/emailOnAway.java
0 → 100644
View file @
c2f2f325
package
com
.
tempstop
;
import
org.jivesoftware.messenger.MessageRouter
;
import
org.jivesoftware.messenger.Session
;
import
org.jivesoftware.messenger.XMPPServer
;
import
org.jivesoftware.messenger.container.Plugin
;
import
org.jivesoftware.messenger.container.PluginManager
;
import
org.jivesoftware.messenger.interceptor.InterceptorManager
;
import
org.jivesoftware.messenger.interceptor.PacketInterceptor
;
import
org.jivesoftware.messenger.interceptor.PacketRejectedException
;
import
org.jivesoftware.messenger.user.UserManager
;
import
org.jivesoftware.messenger.user.UserNotFoundException
;
import
org.jivesoftware.messenger.user.User
;
import
org.jivesoftware.messenger.PresenceManager
;
import
org.jivesoftware.messenger.vcard.VCardManager
;
import
org.jivesoftware.util.JiveGlobals
;
import
org.jivesoftware.util.EmailService
;
import
org.xmpp.packet.Presence
;
import
org.xmpp.packet.JID
;
import
org.xmpp.packet.Message
;
import
org.xmpp.packet.Packet
;
//import java.io.File;
import
java.io.*
;
public
class
emailOnAway
implements
Plugin
,
PacketInterceptor
{
private
InterceptorManager
interceptorManager
;
private
UserManager
userManager
;
private
PresenceManager
presenceManager
;
private
EmailService
emailService
;
private
MessageRouter
messageRouter
;
private
VCardManager
vcardManager
;
public
emailOnAway
()
{
interceptorManager
=
InterceptorManager
.
getInstance
();
emailService
=
EmailService
.
getInstance
();
messageRouter
=
XMPPServer
.
getInstance
().
getMessageRouter
();
presenceManager
=
XMPPServer
.
getInstance
().
getPresenceManager
();
userManager
=
XMPPServer
.
getInstance
().
getUserManager
();
vcardManager
=
VCardManager
.
getInstance
();
}
public
void
initializePlugin
(
PluginManager
pManager
,
File
pluginDirectory
)
{
// register with interceptor manager
interceptorManager
.
addInterceptor
(
this
);
}
public
void
destroyPlugin
()
{
// unregister with interceptor manager
interceptorManager
.
removeInterceptor
(
this
);
}
private
Message
createServerMessage
(
String
to
,
String
from
,
String
emailTo
)
{
Message
message
=
new
Message
();
message
.
setTo
(
to
);
message
.
setFrom
(
from
);
message
.
setSubject
(
"I'm away"
);
message
.
setBody
(
"I'm currently away. Your message has been forwarded to my service email address ("
+
emailTo
+
")."
);
return
message
;
}
public
void
interceptPacket
(
Packet
packet
,
Session
session
,
boolean
read
,
boolean
processed
)
throws
PacketRejectedException
{
String
emailTo
=
null
;
String
emailFrom
=
null
;
if
((!
processed
)
&&
(!
read
)
&&
(
packet
instanceof
Message
)
&&
(
packet
.
getTo
()
!=
null
))
{
Message
msg
=
(
Message
)
packet
;
if
(
msg
.
getType
()
==
Message
.
Type
.
chat
)
{
try
{
User
userTo
=
userManager
.
getUser
(
packet
.
getTo
().
getNode
());
if
(
presenceManager
.
getPresence
(
userTo
).
toString
().
toLowerCase
().
indexOf
(
"away"
)
!=
-
1
)
{
// Status isn't away
if
(
msg
.
getBody
()
!=
null
)
{
// Build email/sms
// The to email address
emailTo
=
vcardManager
.
getVCardProperty
(
userTo
.
getUsername
(),
"EMAIL"
);
if
(
emailTo
==
null
||
emailTo
.
length
()
==
0
)
{
emailTo
=
vcardManager
.
getVCardProperty
(
userTo
.
getUsername
(),
"EMAIL:USERID"
);
if
(
emailTo
==
null
||
emailTo
.
length
()
==
0
)
{
emailTo
=
userTo
.
getEmail
();
if
(
emailTo
==
null
||
emailTo
.
length
()
==
0
)
{
emailTo
=
packet
.
getTo
().
getNode
()
+
"@"
+
packet
.
getTo
().
getDomain
();
}
}
}
// The From email address
User
userFrom
=
userManager
.
getUser
(
packet
.
getFrom
().
getNode
());
emailFrom
=
vcardManager
.
getVCardProperty
(
userFrom
.
getUsername
(),
"EMAIL"
);
if
(
emailFrom
==
null
||
emailFrom
.
length
()
==
0
)
{
emailFrom
=
vcardManager
.
getVCardProperty
(
userFrom
.
getUsername
(),
"EMAIL:USERID"
);
if
(
emailFrom
==
null
||
emailFrom
.
length
()
==
0
)
{
emailFrom
=
userFrom
.
getEmail
();
if
(
emailFrom
==
null
||
emailFrom
.
length
()
==
0
)
{
emailFrom
=
packet
.
getFrom
().
getNode
()
+
"@"
+
packet
.
getFrom
().
getDomain
();
}
}
}
// System.err.println(vcardManager.getVCardProperty(userTo.getUsername(), "EMAIL:USERID"));
// Send email/sms
// if this is an sms... modify the recipient address
emailService
.
sendMessage
(
userTo
.
getName
(),
emailTo
,
userFrom
.
getName
(),
emailFrom
,
"IM"
,
msg
.
getBody
(),
null
);
// Notify the sender that this went to email/sms
messageRouter
.
route
(
createServerMessage
(
packet
.
getFrom
().
getNode
()
+
"@"
+
packet
.
getFrom
().
getDomain
(),
packet
.
getTo
().
getNode
()
+
"@"
+
packet
.
getTo
().
getDomain
(),
emailTo
));
}
}
}
catch
(
UserNotFoundException
e
)
{
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment